adding multiple entries to a HashMap at once in one statement
You can use the Double Brace Initialization as shown below: Map<String, Integer> hashMap = new HashMap<String, Integer>() {{ put(“One”, 1); put(“Two”, 2); put(“Three”, 3); }}; As a piece of warning, please refer to the thread Efficiency of Java “Double Brace Initialization” for the performance implications that it might have.