Skip to content

ithsjava25/ithsjava25-java-project-webserver-maven-java-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Create Your First Java Program

Java has evolved to become more beginner-friendly. This guide walks you through creating a simple program that prints “Hello World,” using both the classic syntax and the new streamlined approach introduced in Java 21.


✨ Classic Java Approach

Traditionally, Java requires a class with a main method as the entry point:

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

This works across all Java versions and forms the foundation of most Java programs.


🆕 Java 25: Unnamed Class with Instance Main Method

In newer versions like Java 25, you can use Unnamed Classes and an Instance Main Method, which allows for a much cleaner syntax:

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

💡 Why is this cool?

  • ✅ No need for a public class declaration
  • ✅ No static keyword required
  • ✅ Great for quick scripts and learning

To compile and run this, use:

java --source 25 HelloWorld.java

📚 Learn More

This feature is part of Java’s ongoing effort to streamline syntax. You can explore deeper in Baeldung’s guide to Unnamed Classes and Instance Main Methods.

About

ithsjava25-java-project-webserver-maven-java-template created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages