Java Map

The collection interface that associates each unique key with one value, replacing the old value when a key is stored again.

In more detail

get(key) looks a value up and put(key, value) stores one. HashMap iterates in no particular order; LinkedHashMap keeps insertion order, which matters when a map is displayed or serialized. Collectors.groupingBy produces a map from a key to the values sharing it.

Example

private final Map<String, Integer> positions = new LinkedHashMap<>();

Related terms

Taught in

References

Certification courses