Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Java

Knowledge base — Java

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

Entries: 813

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
Java

LongAdder: updating, reading, and resetting

Use `LongAdder` to collect statistics updated by multiple threads. Learn which methods change the total, when a read is exact, and why `sumThenReset()` does not create an atomic boundary between reporting intervals.

Advanced · Java SE 21