import java.util.Enumeration;
导入 java.util.Hashtable;
public class removeAll_Hashtable {
public static void main(String[] s) {
Hashtable table = new Hashtable();
table.put(1”, val1”);
table.put(2”, val2”);
table.put(3”, val3”);
枚举 e = table.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
System.out.println(key + : ” + table.get(key));
table.remove(key);
}
System.out.println(删除后”);
System.out.println(表);
}
}
3: val3
2: val2
1: val1
删除后
{}
import java.util.Hashtable;
public class removeAll_Hashtable {
public static void main(String[] s) {
Hashtable table = new Hashtable();
table.put(1”, val1”);
table.put(2”, val2”);
table.put(3”, val3”);
table.clear();
System.out.println(调用 clear() 之后”);
System.out.println(表);
}
}
调用 clear()后
{}
Please disable your ad blocker and refresh the window to use this website.