4 ms·
var ages = Map.of("sarah",19, "dan",35); //valid java
by kubota 4y ago
var ages = Map.of("sarah",19, "dan",35); //valid java
- jmartrican 4y agoMap.of came out in JDK 9. I think there are still a lot of companies using JDK 8.... uhg. Maybe OP is one of the poor souls stuck in JDK 8.
- cesarb 4y agoFor those of us still using Java 8, ImmutableMap.of() (from Guava) is similar (and probably the inspiration for Map.of()), as long as you don't need your Map to be modified later.
- erik_seaberg 4y agoWe’re still using Java 8 in prod, because Java 9 broke our Hive version and a lot of other use cases for reflection (in return for modularizing stdlib, which we never cared about). I think some projects gave up on Java 9 as it neared EOL, and Java 11 compatibility still isn’t finished.
- jmartrican 4y agoNice touch using "var" to show that off too.
- ferd 4y agoNice, glad to see that added to the standard API (even if a bit too late). Stressing the point: this welcomed improvement on the API is a lot more than "saving keystrokes".
- RockingGoodNite 4y agovar and static must die.