Exploring New Features in JDK 23: A Sneak Peek
The main method and println
With JDK 23 on the horizon, I decided to dive into some of its new features by running the following code in the CLI:
Here is the output:
One key observation is that readln captures input as strings without automatic type conversion, unlike Python. This behavior is expected but worth noting. Although this feature is still in the preview phase, it shows great potential for future enhancements.
The New java.io.IO Class
The new java.io.IO class introduces three additional methods: println, print, and readln, which are automatically imported. This makes it easier for beginners as there's no need for extra import statements.
Building JDK 23 from Source
Since JDK 23 isn't officially available yet, I had to build it from the source. However, once Rampdown Phase One begins on June 6, 2024, you'll be able to download it directly. It will also be available through SDKMAN for easier management and installation.
Conclusion
The upcoming JDK 23 release promises to introduce convenient features for developers, particularly beginners. The new IO class is a great example, simplifying input and output operations. As we await the official release, building from the source gives us an exciting preview of what’s to come.
More about this can be found here: https://www.infoq.com/news/2024/05/jep477-implicit-classes-main/