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");
Enumeration e = table.keys();
while (e.hasMoreElements()) {
String cle = (String) e.nextElement();
System.out.println(cle + " : " + table.get(cle));
table.remove(cle);
}
System.out.println("Après suppression");
System.out.println(table);
}
}
3 : val3
2 : val2
1 : val1
Après suppression
{}
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("Après appel de clear()");
System.out.println(table);
}
}
Après appel de clear()
{}
Please disable your ad blocker and refresh the window to use this website.