fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Basic {
  8. public static void main(String a[]){
  9. Hashtable<String,String> ht = new Hashtable<String,String>();
  10. ht.put("first", "FIRST INSERTED");
  11. ht.put("second", "SECOND INSERTED");
  12. ht.put("third","THIRD INSERTED");
  13. System.out.println(ht);
  14. System.out.println("Value of key 'second': "+ht.get("second"));
  15. System.out.println("Is Hashtable empty? "+ht.isEmpty());
  16. ht.remove("third");
  17. System.out.println(ht);
  18. System.out.println("Size of the Hashtable: "+ht.size());
  19. }
  20. }
Success #stdin #stdout 0.07s 3359744KB
stdin
Standard input is empty
stdout
{third=THIRD INSERTED, second=SECOND INSERTED, first=FIRST INSERTED}
Value of key 'second': SECOND INSERTED
Is Hashtable empty? false
{second=SECOND INSERTED, first=FIRST INSERTED}
Size of the Hashtable: 2