Initializing HashMaps in Java

How can I initialize a HashMap with some pre-defined entries? In this article I’ll show you how you create a HashMap with values. Java doesn’t provide a method like Array.asList(). For initializing a map you have to implement something like that: So this is the double brace initialization idom. I don’t like this way. It’s not very readable, it’s creates a […]