MacMusic  |  PcMusic  |  440 Software  |  440 Forums  |  440TV  |  Zicos
java
Search

The best new features in Java 25

Wednesday October 22, 2025. 11:00 AM , from InfoWorld
Java continues its fast and feature-packed release schedule, with JDK 25 delivering syntax improvements, simplifications, and performance enhancements. This article looks at the core updates in Java 25, with code and usage examples. JDK 25 is now the most current long-term support (LTS) release, and it’s packed with new features to explore.

Simpler source files and instance main methods

Over the years, Java has consistently moved away from its verbose syntax and toward greater simplicity. A longstanding hurdle for Java beginners was the verbosity of defining even a simple “Hello World” program:

public class HelloWorld {
public static void main(String[] args) {
System.out.println('Hello, InfoWorld!');
}
}

A beginner had to either ignore mysterious keywords like public, class, and static or learn about visibility, classes, and static members before ever touching on Java syntax basics.

Java 25 addresses this issue with JEP 512: Compact source files and instance main methods, which lets us write the same program as:

void main() {
IO.println('Hello, World!');
}

The most obvious thing to notice is that all the OOP syntax is gone. Of course, you can add this code back in as needed. But also notice the IO.println() call. The basic IO libraries were moved into the Java IO package, which is part of java.lang and does not require an explicit import. This addresses another longstanding gripe for Java developers, of how much code was required simply to output to the console.

New flexible constructors

Another win for flexibility over formality, JEP 513: Flexible constructor bodies lands in Java 25, following a long incubation period. Flexible constructors, as the name suggests, make constructors less rigid. Specifically, Java no longer requires calling super() or this() as the first thing that happens in a constructor.

Previously, even if you did not explicitly call super() or this(), the compiler would do it for you. And, if you tried calling them elsewhere, it would cause an error. All of this is now more flexible.

There still are some rules that must be observed, but it’s now possible to run initialization code on the class itself before calling super(). This avoids situations where you might have to do additional work because the subclass initialization obviates the superclass initialization. (For more about this, look at the Person->Employee example for JEP 513.)

To fully understand the benefits of flexible constructors, consider an example where you have a Shape superclass, and you want the constructor to accept an area:

class Shape {
final int area;
public Shape(int area) {
if (area
https://www.infoworld.com/article/4075736/7-key-features-in-java-25.html

Related News

News copyright owned by their original publishers | Copyright © 2004 - 2025 Zicos / 440Network
Current Date
Oct, Wed 22 - 23:54 CEST