Is there some way of initializing a Java HashMap like this?:
Map test =
new HashMap{\"test\":\"test\",\"test\
If you allow 3rd party libs, you can use Guava's ImmutableMap to achieve literal-like brevity:
Map test = ImmutableMap.of("k1", "v1", "k2", "v2");
This works for up to 5 key/value pairs, otherwise you can use its builder:
Map test = ImmutableMap.builder()
.put("k1", "v1")
.put("k2", "v2")
...
.build();