摘要: Guava提供了比JDK集合工具类Collections更多,更方便的操作集合的方法以下是相应接口所对应的工具类InterfaceJDK or Guava?Corresponding Guava utility classCollectionJDKCollections2(avoiding conflict withjava.util.Collections)ListJDKListsSetJDKSetsSortedSetJDKSetsMapJDKMapsSortedMapJDKMapsQueueJDKQueuesMultisetGuavaMultisetsMultimapGuavaMultim 阅读全文
posted @ 2013-10-12 16:04 jake- 阅读(657) 评论(0) 推荐(0) 编辑
摘要: Guava提供了很多新的集合类型(这部分也是目前使用最广的)1.MultisetThe traditional Java idiom for e.g. counting how many times a word occurs in a document is something like:Map counts =newHashMap();for(String word : words){ Integer count = counts.get(word); if(count ==null){ counts.put(word,1); }else{ counts.put(word... 阅读全文
posted @ 2013-10-11 11:56 jake- 阅读(544) 评论(0) 推荐(0) 编辑
摘要: 通篇看下来,主要讲Immutable Collections在防御性编程上的应用首先要先了解下defensive copyhttp://blog.csdn.net/tounaobun/article/details/8607174官方wiki的介绍也基本是讲 Immutable Collections主要用在防御性编程上会使程序更安全,并且对比了jdk的Collections.unmodifiableXXXmethods优势:Immutable objects have many advantages, including:Safe for use by untrusted libraries 阅读全文
posted @ 2013-10-11 10:33 jake- 阅读(161) 评论(0) 推荐(0) 编辑