fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Basic {
  8.  
  9. public static void main(String a[]){
  10.  
  11. LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();
  12. lhm.put("one", "This is first element");
  13. lhm.put("two", "This is second element");
  14. lhm.put("four", "this element inserted at 3rd position");
  15. System.out.println(lhm);
  16. System.out.println("Getting value for key 'one': "+lhm.get("one"));
  17. System.out.println("Size of the map: "+lhm.size());
  18. System.out.println("Is map empty? "+lhm.isEmpty());
  19. System.out.println("Contains key 'two'? "+lhm.containsKey("two"));
  20. System.out.println("Contains value 'This is first element'? "
  21. +lhm.containsValue("This is first element"));
  22. System.out.println("delete element 'one': "+lhm.remove("one"));
  23. System.out.println(lhm);
  24. }
  25. }
Success #stdin #stdout 0.06s 3359744KB
stdin
Standard input is empty
stdout
{one=This is first element, two=This is second element, four=this element inserted at 3rd position}
Getting value for key 'one': This is first element
Size of the map: 3
Is map empty? false
Contains key 'two'? true
Contains value 'This is first element'? true
delete element 'one': This is first element
{two=This is second element, four=this element inserted at 3rd position}