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. test("one", false);
  14. test("two", false);
  15. test("three", false);
  16. test("four", false);
  17. test("five", false);
  18. test("six", true); // same order till here
  19. test("seven", true);
  20. }
  21.  
  22. private static void test(String text, boolean print) {
  23. map.put(text, text);
  24. if (print) {
  25. map.forEach((id, name) -> System.out.println(id + ": " + name));
  26. System.out.println();
  27. }
  28. }
  29. }
Success #stdin #stdout 0.11s 57848KB
stdin
Standard input is empty
stdout
six: six
two: two
three: three
five: five
four: four
one: one

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