标签:nbsp employee 对象 nts count mes src tag map
//JDK
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
//Guava
List<String> list = Lists.newArrayList("a", "b", "c", "d");
Multiset<String> multiset = HashMultiset.create();
// 统计每次单词出现的次数
for (String word : words) {
multiset.add(word);
}
// 输出单词的输出次数
for (String word : multiset.elementSet()) {
multiset.count(word);
}
Multimap<Integer, People> multimap = ArrayListMultimap.create();
// 统计同一年纪的 People 对象
for (People people : peopleList) {
multimap.put(people.getAge(), people);
}
// 输出统计结果
for (Integer key : multimap.keySet()) {
List<People> peoples = Lists.newArrayList(multimap.get(key));
System.out.println(peoples);
}
//JDK
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
//Guava
List<String> list = Lists.newArrayList("a", "b", "c", "d");
Multiset<String> multiset = HashMultiset.create();
// 统计每次单词出现的次数
for (String word : words) {
multiset.add(word);
}
// 输出单词的输出次数
for (String word : multiset.elementSet()) {
multiset.count(word);
}
Multimap<Integer, People> multimap = ArrayListMultimap.create();
// 统计同一年纪的 People 对象
for (People people : peopleList) {
multimap.put(people.getAge(), people);
}
// 输出统计结果
for (Integer key : multimap.keySet()) {
List<People> peoples = Lists.newArrayList(multimap.get(key));
System.out.println(peoples);
}
BiMap<Integer, String> empIDNameMap = HashBiMap.create();
empIDNameMap.put(new Integer(101), "Mahesh");
empIDNameMap.put(new Integer(102), "Sohan");
empIDNameMap.put(new Integer(103), "Ramesh");
//Emp Id of Employee "Mahesh"
System.out.println(empIDNameMap.inverse().get("Mahesh"));
标签:nbsp employee 对象 nts count mes src tag map
原文地址:https://www.cnblogs.com/vhyc/p/10669595.html