fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class ValueSearch {
  8. public static void main(String a[]){
  9. TreeMap<String, String> hm = new TreeMap<String, String>();
  10. //add key-value pair to TreeMap
  11. hm.put("first", "FIRST INSERTED");
  12. hm.put("second", "SECOND INSERTED");
  13. hm.put("third","THIRD INSERTED");
  14. System.out.println(hm);
  15. if(hm.containsValue("SECOND INSERTED")){
  16. System.out.println("The TreeMap contains value SECOND INSERTED");
  17. } else {
  18. System.out.println("The TreeMap does not contains value SECOND INSERTED");
  19. }
  20. if(hm.containsValue("first")){
  21. System.out.println("The TreeMap contains value first");
  22. } else {
  23. System.out.println("The TreeMap does not contains value first");
  24. }
  25. }
  26. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
{first=FIRST INSERTED, second=SECOND INSERTED, third=THIRD INSERTED}
The TreeMap contains value SECOND INSERTED
The TreeMap does not contains value first