首页 > 编程语言 > 详细

java HashMap and HashMultimap 区别

时间:2017-04-30 16:51:53      阅读:391      评论:0      收藏:0      [点我收藏+]

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);

java HashMap and HashMultimap 区别

原文:http://www.cnblogs.com/qbmiller/p/6789659.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!