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