排序的hashmap(guava)

1.mvnrepository上搜索 guava。并引用其jar包

类似compile "com.google.guava:guava:18.0"

测试代码

Builder<String, String> b2 = ImmutableSortedMap.naturalOrder();
b2.put("sta_1111", "sta_1111");
b2.put(
"sta_2222", "sta_2222"); b2.put("sys_1123", "sys_1123"); b2.put("sta_1122", "sta_1122"); b2.put("sys_1122", "sys_1122");
ImmutableSortedMap
<String, String> map = b2.build(); for(Entry<String, String> entry : map.entrySet()) { System.out.println(entry.getKey()); }

 

posted @ 2016-04-15 13:23  無限大  阅读(1307)  评论(0编辑  收藏  举报