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

LongAdder: increment, add, and read the sum

Use `increment()` to count one, `add(long)` to apply a delta, and `sum()` to read the total. Learn how to merge partial totals and when the read gives an exact result.

Advanced · Java SE 21
Java

Long: selecting minimum and maximum values and type bounds

Long.max and Long.min select the greater or smaller of two long values. Long.MIN_VALUE and Long.MAX_VALUE define the type's bounds, rather than a comparison result.

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

Map.Entry — a key-value pair

Map.Entry<K,V> represents one key-value pair. The getKey() method reads its key, while getValue() reads its value. An entry may be connected to a map or exist independently of one.

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

Map.Entry.getKey — reading an entry's key

Map.Entry.getKey() returns the key of one map entry as a value of type K. It takes no arguments; distinguish the entry's key from its value.

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

Map.Entry.getValue — read an entry's value

Map.Entry.getValue() reads the value of one key–value pair. It takes no arguments and returns the type V specified by Map.Entry<K,V>.

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

Map.get — look up a value by key

Use `map.get(key)` to retrieve a stored value. If the map allows `null` values, the result alone cannot distinguish a missing key from one explicitly mapped to `null`.

Basic · Java SE 21
Java

Map key-set view: `Map.keySet()`

`Map.keySet()` returns a set of keys backed by the map. Changes to the map appear in the view, and removing a key through the view removes its mapping if removal is supported.

Advanced · Java SE 21
Java

Map.merge(): combine values for one key

Use `Map.merge()` to store an initial value, combine it with an existing value, or remove the entry when the combining function returns `null`.

Basic · Java SE 21
Java

Map.put — insert or replace a value

Store a value under a key and get back the previous value. Learn when a `null` result means the key was absent and when it means the key already mapped to `null`.

Basic · Java SE 21
Java

Map.size() — Count entries in a map

`Map.size()` returns the current number of key–value mappings as an `int`. Replacing the value for an existing key does not increase the size.

Basic · Java SE 21
Java

Map.values() — the map’s values view

`Map.values()` returns a collection backed by the map. Iterate over it to sum counters without looking up their keys or dropping repeated values.

Basic · Java SE 21