Java's Quiet Change: No Static Main Method Required

View profile for Gurjeet Singh

Brand partnership

There is quiet change in Java that every Java Developer should know about👀 I still remember the first Java program I ever wrote like every beginner, I memorized this line like a ritual : `public static void main(String[] args)`   But here’s the surprising part In modern Java (21+), you can now write: void main() {     System.out.println("Hello World"); }   Yes… no `static`. 😮 So what actually changed?   **Old JVM behaviour** When a Java program starts: 1️⃣ JVM loads the class 2️⃣ No objects exist yet 3️⃣ JVM looks for a method it can call directly   Since non-static methods need an object, Java forced us to use a static `main()`. That’s why we all memorized that signature. But in Modern JVM behavior (Java 21 → 25) JVM quietly does this behind the scenes: ```java new Main().main(); ``` It creates the object and calls the method for you.   This change actually pushes Java closer to being more object-oriented, because now your program can start from an instance method instead of a static one.   Next time, let’s discuss a fun debate Why Java is still NOT a 100% Object-Oriented language.   Did you know this change already happened?   #Java #Programming #JVM #SoftwareEngineering #Developers

  • text

To view or add a comment, sign in

Explore content categories