fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. private static final HashMap<String, String> map = new HashMap<>(2, 0.8f);
  11.  
  12. public static void main(String[] args) throws Exception {
  13. map.put("one", "one");
  14. map.put("two", "two");
  15. map.put("three", "three");
  16. map.put("four", "four");
  17. map.put("five", "five");
  18. map.put("six", "six");
  19. print();
  20. map.put("seven", "seven");
  21. map.remove("seven");
  22. print();
  23. }
  24.  
  25. private static void print() {
  26. map.forEach((id, name) -> System.out.println(id + ": " + name));
  27. System.out.println();
  28. }
  29. }
Success #stdin #stdout 0.18s 55820KB
stdin
Standard input is empty
stdout
six: six
two: two
three: three
five: five
four: four
one: one

six: six
four: four
one: one
two: two
three: three
five: five