2 ms·
The Collections class built into Java has a lot of timesavers like this too--singleton, singleonList, singletonMap, and Arrays has stuff like Arrays.asList( ...
by bpodgursky 16y ago
The Collections class built into Java has a lot of timesavers like this too--singleton, singleonList, singletonMap, and Arrays has stuff like Arrays.asList( ... ).
Also it's rarely important that you know the actual type of Map you're using (the interface is what's important), so you can just call
Map<String, Integer> foo = Maps.newHashMap();