1、API介绍
2、构造方法
3、特有功能方法
import java.util.Enumeration;
import java.util.Hashtable;
public class Demo4_Hashtable {
public static void main(String[] args) {
Hashtable<String, String> map = new Hashtable<>();
map.put("cn", "china");
map.put("en", "english");
map.put("us", "america");
map.put("jp", "japan");
//.elements() 获取包含所有值的枚举器
for (Enumeration<String> elements = map.elements(); elements.hasMoreElements(); ) {
String value = elements.nextElement();
System.out.println(value);
}
//.keys() 获取包含所有键的枚举器
for (Enumeration<String> keys = map.keys(); keys.hasMoreElements(); ) {
String key = keys.nextElement();
String value = map.get(key);
System.out.println(key + "..." + value);
}
}
}