Fundamentals 3 min read

How Java 21 Simplifies Hello World with Unnamed Classes and New Launch Protocol

Java 21 introduces unnamed classes and a new launch protocol (JEP 445) that dramatically reduce boilerplate, allowing a Hello World program to be written without public, static, or parameter declarations, making the language more beginner‑friendly.

Programmer DD
Programmer DD
Programmer DD
How Java 21 Simplifies Hello World with Unnamed Classes and New Launch Protocol

Java 21 adds two language core features: unnamed classes and a new launch protocol (JEP 445) that let programs run with far less boilerplate.

Traditional Hello World in Java requires a public class, a static main method with a String[] argument, and explicit public modifiers:

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

The article points out that these elements are unnecessary for a simple example and can confuse beginners.

Using JEP 445, the same program can be written as:

class HelloWorld {
    void main() {
        System.out.println("Hello, World!");
    }
}

Furthermore, Java 21 introduces unnamed classes, allowing the program to be reduced to a single method without a class declaration:

void main() {
    System.out.println("Hello, World!");
}

These changes make Java’s entry‑level code as concise as that of Python or Go, potentially lowering the learning curve for newcomers.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaJava 21Hello WorldJEP 445Launch ProtocolUnnamed Classes
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.