Is there a Java equivalent of Python's defaultdict?

后端 未结 8 1633
失恋的感觉
失恋的感觉 2021-02-05 00:05

In Python, the defaultdict class provides a convenient way to create a mapping from key -> [list of values], in the following example,



        
8条回答
  •  甜味超标
    2021-02-05 00:36

    in addition to apache collections, check also google collections:

    A collection similar to a Map, but which may associate multiple values with a single key. If you call put(K, V) twice, with the same key but different values, the multimap contains mappings from the key to both values.

提交回复
热议问题