A source file no longer needs an explicit class declaration, and main need not be public, static, or take String[]. Final in 25 after previews starting in 21.
The problem it solved
Java's first program required a class, a public static void main, and an unused String[] parameter — five concepts before printing a line, all of which had to be taken on faith.
How you did it before
Every teaching example began with public class Main plus public static void main(String[] args), and instructors spent the first lesson explaining keywords the student could not yet use.
Journey: Preview in 21 (JEP 445), evolved through 22 and 24, final in 25.
Asked as
- Can a Java program run without a class declaration?
- Does main still have to be static?
- Why did it take until Java 25 to simplify Hello World?
Scenario question
You are writing training material for developers new to Java, and your organisation is on JDK 17 in production but can use 25 for learning.
Do you teach the compact form or the classic form first?
What a good answer weighs
Either is defensible, but the reason matters. Teaching compact first removes five upfront concepts; teaching classic first means their code matches production and every existing tutorial. The strong answer names the trade rather than picking on preference, and notes that the compact form is a source-file convenience, not a different language.