java HashMap and HashMultimap 区别

http://stackoverflow.com/questions/19222029/what-is-difference-between-hashmap-and-hashmultimap

 


The difference is that with the second, Core Java implementation,

you need to check whether the Set is there before you insert. Guava's Multimap takes care of that for you.

With Core Java:

Set<String> innerSet = opt.get(key);
if (innerSet == null) {
innerSet = new HashSet<String>();
opt.put(key, innerSet);
}
innerSet.add(value);
With Guava:

opt.put(key, value);

posted @ 2017-04-30 16:02  義丨往昔灬miller  阅读(857)  评论(0编辑  收藏  举报