Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    var ages = Map.of("sarah",19, "dan",35);   //valid java


Nice, 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".


Map.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.


For 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.


We’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.


Nice touch using "var" to show that off too.


var and static must die.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: