java hashtable 排序问题
2020-11-22 18:31
标签:blog class code java get string int set cti line com hashtable默认以主键降序存储,包括数值和字符串主键,对象类型主要未测试。 java hashtable 排序问题,搜素材,soscw.com java hashtable 排序问题 标签:blog class code java get string int set cti line com 原文地址:http://www.cnblogs.com/cloudapex/p/3700938.html
Hashtable
new
Hashtable
h.put(
"6"
,
"666"
);
h.put(
"8"
,
"888"
);
h.put(
"2"
,
"222"
);
for
(String key : h.keySet())
System.out.println(key);
System.out.println(
"----------------------------------------------------------"
);
List
new
ArrayList
Collections.sort(v,
new
Comparator
public
int
compare(Object arg0, Object arg1) {
return
Integer.valueOf(arg0.toString()) - Integer.valueOf(arg1.toString());
// 升序,参数顺序对调时降序
}});
for
(String key : v)
System.out.println(key +
" "
+ h.get(key));