2 ms·
Map m = new HashMap(); m.put("a", 1); m.put("b", 2); m.put("c", 3); . . . The single worst thing in Java?
by jmmcd 15y ago
Map m = new HashMap();
m.put("a", 1);
m.put("b", 2);
m.put("c", 3);
.
.
.
The single worst thing in Java?
- eonwe 15y agoI think the current way to write that is to either use Google Guave ImmutableMap.of("a", 1, "b", 2, "c", 3) or when mutable maps are required, to write: Map m = new HashMap() {{ put("a", 1); put("b", 2); put("c", 3); }}; Both of these are a bit lighter yet still far away from JavaScript or Ruby special syntaxes.