Compact source files
Write a complete program without class declaration or public static void main.
Porównanie kodu
✕ Java 8
public class HelloWorld {
public static void main(String[] args) {
System.out.println(
"Hello, World!");
}
}
✓ Java 25
void main() {
IO.println("Hello, World!");
}
Widzisz problem z tym kodem? Daj nam znać.
Dlaczego nowoczesne podejście wygrywa
Zero ceremony
No class, no public static void main, no String[] args.
Beginner-friendly
New programmers can write useful code from line 1.
Script-like
Perfect for quick prototypes, scripts, and examples.
Stare podejście
Main Class Ceremony
Nowoczesne podejście
void main()
Od JDK
25
Poziom trudności
Początkujący
Wsparcie JDK
Compact source files
Dostępne
Finalized in JDK 25 LTS (JEP 512, Sept 2025).
Jak to działa
Compact source files remove the ceremony of class declarations and the main method signature for simple programs. Combined with implicit import of java.io.IO, even println is available directly.
Powiązana dokumentacja