What does deterministic mean?

Nathan Schwermann picture Nathan Schwermann · Aug 25, 2010 · Viewed 8.9k times · Source

I am reading the Java Hashmap documentation but I don't understand this sentence.

Note that the iteration order for HashMap is non-deterministic. If you want deterministic iteration, use LinkedHashMap.

What does deterministic mean?

Answer

bukzor picture bukzor · Aug 25, 2010

The simplest definition:

Given the same inputs, you always get the same outputs.

Above, it's saying that iterating through the exact same HashMap may give different results at different times, even when you haven't changed anything. Usually that doesn't matter, but if it does, you should use a LinkedHashMap.