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. private static final Map<String, Integer> defaults = new HashMap<>();
  11.  
  12. static {
  13. defaults.put("maxUsers", 10);
  14. defaults.put("timeout", 5000);
  15. defaults.put("retries", 3);
  16. }
  17.  
  18. public static void main(String[] args) {
  19. Map<String, Integer> config = new HashMap<>(defaults);
  20.  
  21. for (String key : config.keySet()) {
  22. // Update values based on some "dynamic" logic
  23. config.put(key, config.get(key) + key.length());
  24. }
  25.  
  26. System.out.println("Final config: " + config);
  27. }
  28. }
Success #stdin #stdout 0.17s 55444KB
stdin
Standard input is empty
stdout
Final config: {maxUsers=18, retries=10, timeout=5007}