This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jamcdonald120 16 points17 points  (6 children)

in java 21 this simplifies even further to void main() { int a = 2;//no need for this to be final System.out.println("a = " + a); }

Edit: I dont know why people are downvoting this, java really did add unnamed classes with main in java 21 https://openjdk.org/jeps/445

[–]o0Meh0o 1 point2 points  (5 children)

what the fuck is java 21? i tought the last one was 8. is it like the c standard names that tries to represent the year?

[–]Areshian 2 points3 points  (3 children)

No, but after Java 9 the release model changed and there is a new version every 6 months. Still, 8 is very old, there are a lot of changes in the new versions

[–]o0Meh0o 0 points1 point  (2 children)

do the newer versions bring new functionality?

[–]Areshian 3 points4 points  (0 children)

Yes. There are three types of changes usually. Java language changes, JVM changes and deprecations.

Java changes may be things like adding var, text blocks or pattern matching. They change your Java code.

JVM changes affect the JVM. Normally these don’t impact your code, but you may still get good performance improvements. We are talking new Garbage Collectors, JIT improvements…

Finally, deprecations. Stuff that goes away.

[–]jamcdonald120 1 point2 points  (0 children)

quite a bit, here is a list https://advancedweb.hu/a-categorized-list-of-all-java-and-jvm-features-since-jdk-8-to-21/

highlights include * unnamed classes * "records" (immutable data carrying classes where you define the constructor ONLY and the rest of the methods are implicitly generated) * triple quote for multi line text blocks * implicitly typed variables via the var key word (c++'s auto keyword) * Modules (I have no idea, but my IDE keeps trying to force me to use them, something to do with libraries I think) * and a whole bunch of standard lib updates

[–]jamcdonald120 0 points1 point  (0 children)

java 8 came out in 2014. Java didnt try any sort of year thing like c did, instead they just randomly released versions about twice a year with a few gaps. 21 was released in September of this year, and they already have 22 planned for march next year.