import java.util.Enumeration;
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");
列挙型 e = table.keys();
while (e.hasMoreElements()) {
文字列 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.