JAVA Hashtable

概述

和HashMap类很相似

注意:
1、它的key和value不允许为空
2、是线程安全的,效率较低,用的少

常用的方法和HashMap一样。

例子

Map map = new Hashtable();

map.put("id", "1341234");
map.put("name", "鹿晗");

Iterator<Map.Entry> it = map.entrySet().iterator();
while(it.hasNext()){
    Map.Entry en=it.next();
    System.out.println(en.getKey()+"---"+en.getValue());
}

原文出处:/show_1EF4sNCcd9b0.html