fork 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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Map<String, Integer> test = new HashMap<>();
  13. test.put("First", 1);
  14. test.put("Second", 2);
  15. test.put("Third", 3);
  16. test.put("Fourth", 3);
  17. test.put("Fifth", 5);
  18.  
  19.  
  20. for(String key:test.keySet()) {
  21. test.put(key, test.get(key) +1);
  22. }
  23. System.out.println(test);
  24.  
  25. }
  26. }
Success #stdin #stdout 0.1s 52548KB
stdin
Standard input is empty
stdout
{Second=3, Third=4, First=2, Fourth=4, Fifth=6}