LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

How do the multimap operations differ from the map operations of the same name?

get(k) returns a collection of values; put(k, v) adds and never overwrites; remove(k, v) removes one pairing, removeAll(k) all of them. keys() lists a key once per entry, keySet() only once.

Operation Map Multimap
get(k) one value or null all values for k
put(k, v) replaces an existing value adds another pairing, keeps the old ones
remove remove(k) deletes the entry remove(k, v) deletes one pairing, removeAll(k) all of k's
size() number of keys number of pairings
keys keySet() keys() with repeats, keySet() without

Example: after put(Schloss, castle) and put(Schloss, lock), size() is 2, keys() is [Schloss, Schloss] and keySet() is {Schloss}. remove(Schloss, castle) leaves (Schloss, lock); removeAll(Schloss) clears both.

From Quiz: ADS / Sets, Maps and Hash Tables | Updated: Dec 01, 2026