Skip to content

Glossary: Data Structures and Algorithms in Java

getOrDefault

A Map method that returns the value for a key, or a fallback you give if the key is missing. `counts.getOrDefault(name, 0) + 1` is the usual way to count items.

Where the book teaches it

Related terms

hash mapnull