LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

Is Python's dict a map or a multimap, and what about Java's java.util.Dictionary?

Both are plain maps: one value per key. Assigning to an existing key replaces the value. Java's Dictionary is a legacy class from Java 1.0; modern code uses the Map interface.

The word "dictionary" suggests a multimap, since a printed dictionary lists several meanings under one word. The library classes with that name do not work like that:

d = {1: "one"}
d[1] = "uno"        # replaces: d == {1: "uno"}

Java's java.util.Dictionary (1995, Java 1.0) is also one value per key, and is obsolete: use java.util.Map with HashMap or TreeMap instead.

To get a real multimap, store a collection as the value: in Python collections.defaultdict(list), in Java Map<K, List<V>> (Java has no standard multimap class). The same trick turns any map into a multimap.

From Quiz: ADS / Sets, Maps and Hash Tables | Updated: Nov 26, 2026