2 ms·
It's not quite as short as you'd like, but since Java 7 came out in 2011, it's been possible to write: EnumMap<FooEnum, BarClass> map = new EnumMap<>(FooEnum
by michaelt 11y ago
It's not quite as short as you'd like, but since Java 7 came out in 2011, it's been possible to write:
EnumMap<FooEnum, BarClass> map = new EnumMap<>(FooEnum.class);
using the "diamond operator" [1]. In fact, my IDE even provides automatic hints to make use of it!
With that said, I do think java has too much pro-long-method-and-variable-name culture.
[1] http://www.javaworld.com/article/2074080/core-java/jdk-7--the-diamond-operator.html http://www.javaworld.com/article/2074080/core-java/jdk-7--th...