fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class KeySearch {
  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. if(hm.containsKey("first")){
  15. System.out.println("The TreeMap contains key first");
  16. } else {
  17. System.out.println("The TreeMap does not contains key first");
  18. }
  19. if(hm.containsKey("fifth")){
  20. System.out.println("The TreeMap contains key fifth");
  21. } else {
  22. System.out.println("The TreeMap does not contains key fifth");
  23. }
  24. }
  25. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
{first=FIRST INSERTED, second=SECOND INSERTED, third=THIRD INSERTED}
The TreeMap contains key first
The TreeMap does not contains key fifth