Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 5788

Java

TreeMap — sorted maps and constructor references

TreeMap orders entries by key. Learn the difference between copying with TreeMap(Map), retaining a comparator with TreeMap(SortedMap), and using the constructor reference TreeMap::new.

Intermediate · Java SE 21; repository runtime, production runtime not attested
Java

util.TreeSet: practical reference

util.TreeSet: practical reference: TreeSet<E> is a TreeMap-backed NavigableSet sorted naturally or by a Comparator, with add, remove, and contains guaranteed O(log n).

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

util.UUID: practical reference

util.UUID: practical reference: UUID represents an immutable 128-bit value; the class methods manipulate the Leach-Salz variant layout, although its constructor can create any UUID variant.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

WeakHashMap — a map with weak keys

WeakHashMap holds keys through weak references: the map alone does not protect them from garbage collection. Learn put, get, containsKey, containsValue, and size, including the distinction between a missing entry and a null value.

Intermediate · Java SE 21; repository runtime, production runtime not attested
Java

An LRU cache with LinkedHashMap

Build a two-entry cache in Java SE 21 and see why reading a key changes which entry will be evicted on the next insertion.

Advanced · Java SE 21
Java

List.add — adding an element to a list

`List.add(E)` appends one element to a list and returns `true` on success. The indexed overload inserts an element at a position you choose.

Basic · Java SE 21
Java

List.addAll — append or insert elements

Use `List.addAll` to append the elements of a collection or insert them at a chosen index. The `boolean` result tells you whether the destination list changed.

Basic · Java SE 21
Java

List.of and List.of() — unmodifiable lists

`List.of` creates an unmodifiable list from the supplied elements. The no-argument `List.of()` returns an empty list. None of the overloads accepts `null` elements.

Basic · Java SE 21
Java

List.set — Replace a list element by index

`List.set(int,E)` replaces the element at an existing index and returns the old element. It neither changes the list's size nor shifts any other elements.

Basic · Java SE 21
Java

List.size() — count the elements in a list

`List.size()` returns the number of elements in a list as an `int`. Use it to check whether there are enough elements or to set an exclusive upper bound for indexing.

Basic · Java SE 21
Java

List.sort — stable list sorting

List.sort reorders an existing list using a comparator or natural ordering while preserving the relative order of elements that compare as equal.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

List.subList — a view of a list range

`List.subList` returns a view backed by the original list, not a copy. The start index is included and the end index is excluded.

Intermediate · Java SE 21
Java

`LocalDate.equals(Object)` — date equality

Use `LocalDate.equals` to check whether two `LocalDate` values represent the same ISO date. Use `isEqual` to compare the underlying day across calendars.

Advanced · Java SE 21