Google Collections 、guava 简单使用
2016-02-14 14:01
393 查看
简化集合的创建
List<Person> personList= Lists.newLinkedList();
Set<Person> personSet= Sets.newHashSet();
Map<String,Person> personMap= Maps.newHashMap();
Integer[] intArrays= ObjectArrays.newArray(Integer.class,10);
简化集合的初始化
Set<String> set = Sets.newHashSet("one","two","three");
List<String> list = Lists.newArrayList("one","two","three");
Map<String, String> map = ImmutableMap.of("ON","TRUE","OFF","FALSE");
List<Person> personList2= Lists.newArrayList(new Person(1, "Ryu"), new Person(2, "Ken"));
Set<Person> personSet2= Sets.newHashSet(new Person(1, "Ryu"), new Person(2, "Ken"));
Map<String,Person> personMap2= ImmutableMap.of("p1", new Person(1, "Ryu"), "p2", new Person(2, "Ken"));
最新maven坐标(Dec 09, 2015) :
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
简化集合的创建
List<Person> personList= Lists.newLinkedList();
Set<Person> personSet= Sets.newHashSet();
Map<String,Person> personMap= Maps.newHashMap();
Integer[] intArrays= ObjectArrays.newArray(Integer.class,10);
简化集合的初始化
Set<String> set = Sets.newHashSet("one","two","three");
List<String> list = Lists.newArrayList("one","two","three");
Map<String, String> map = ImmutableMap.of("ON","TRUE","OFF","FALSE");
List<Person> personList2= Lists.newArrayList(new Person(1, "Ryu"), new Person(2, "Ken"));
Set<Person> personSet2= Sets.newHashSet(new Person(1, "Ryu"), new Person(2, "Ken"));
Map<String,Person> personMap2= ImmutableMap.of("p1", new Person(1, "Ryu"), "p2", new Person(2, "Ken"));
最新maven坐标(Dec 09, 2015) :
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
相关文章推荐
- Django使用Ajax实现页面无刷新评论回复功能
- soapserver的”looks like we got no XML document“解决方法
- Django实现国际化的步骤
- django导出excel
- Bellman-Ford Algorithm and Dijkstra Algorithm
- GOKit全缓动类型gif列表
- 在Sublime Text里开发go
- GoLang channel 用法转的
- go环境配置
- 越狱Season 1-Episode 21: Go
- Codeforces Round #287 (Div. 2) E. Breaking Good(最短路、dp)
- Machine Learning - Linear Regression with One Variable
- 【HDU4416】Good Article Good sentence【后缀数组】
- nefuoj-813:good
- 谷歌将于明年1月彻底弃用Flash广告
- 在Ubuntu14.04中安装ROS Indigo
- 299. Bulls and Cows
- go语言中的defer、panic、recover处理异常
- Machine Learning - An Introduction
- LeetCode Algorithms #83 <Remove Duplicates from Sorted List>