标签:blog class code java get string int set cti line com
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 |
Hashtable<String, String> h = new
Hashtable<String, String>();h.put("6", "666");h.put("8", "888");h.put("2", "222");<br>for
(String key : h.keySet()) System.out.println(key);System.out.println("----------------------------------------------------------");List<String> v = new
ArrayList<String>(h.keySet());Collections.sort(v, new
Comparator<Object>() { public
int compare(Object arg0, Object arg1) { return
Integer.valueOf(arg0.toString()) - Integer.valueOf(arg1.toString()); // 升序,参数顺序对调时降序<br> }});for (String key : v) System.out.println(key + " "
+ h.get(key)); |
hashtable默认以主键降序存储,包括数值和字符串主键,对象类型主要未测试。
java hashtable 排序问题,码迷,mamicode.com
标签:blog class code java get string int set cti line com
原文地址:http://www.cnblogs.com/cloudapex/p/3700938.html