常用第一种方法
private static volatile Hashtable<Integer, Channel> hm = new Hashtable<Integer, Channel>();
java.util.Iterator<Entry<Integer, Channel>> iter = hm.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
//获取key
int key = (Integer) entry.getKey();
//获取Value
channel = (Channel) entry.getValue();
System.out.println("key=" + key);
}
常用第二种方法 性能好 简单
for (Entry<String, Integer> entry : hmp.entrySet()) {
System.err.println("人物hashKey = " + entry.getKey() + ", Value = " + entry.getValue());
}