一文搞懂guava
官方文档翻译
- 了解Lists Sets Maps 等集合类的常用方法了解guava Collections2 和 jdk Collections hutool CollectionUtil了解guava ListenableFuture的 及 Java 原生Future的使用
- 如何获得集合类的迭代器Collections 为什么搞那么多的内部类(为了返回类对象)
// map 拷贝
@Test
public void test4() throws IllegalAccessException {
HashMap hashMap = Maps.newHashMap();
hashMap.put("1","A");
hashMap.put("2","B");
Map res ;
res = ImmutableMap.copyOf(hashMap);
System.out.println(JSON.toJSONString(res));
}
集合类的初始化
// 普通Collection的创建 Listlist = Lists.newArrayList(); Set set = Sets.newHashSet(); Map map = Maps.newHashMap(); // 不变Collection的创建 ImmutableList iList = ImmutableList.of("a", "b", "c"); ImmutableSet iSet = ImmutableSet.of("e1", "e2"); ImmutableMap iMap = ImmutableMap.of("k1", "v1", "k2", "v2");



