Welcome Java 21!

Welcome Java 21. Goodbye “public static void main(String[] args){}.” Yes, you read it right. Java is advancing and making it easier to accomplish more while writing less code. Record, Pattern-matching, var, and switch expressions are some new features.

But on Java 21 (experimental feature), you can simplify your “Hello World”! There is no need to add “public,” “static,” or “String[] args.” There is no need to declare a class.

Pre-Java 21 Hello World

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

Java 21 HelloWorld (preview feature)

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

It doesn’t seen to be a big change. But think from a perspective of a person trying to write Java code for the very first time. Now, you don’t need to learn about access modifiers, static, class declaration before writing your first line of code. It simplifies.

What do you think?

2 thoughts on “Welcome Java 21!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.