Your First Java Program

Let's write a basic Java program that prints Hello, World! to the console.

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

Explanation:

  • public class Main: Declares a class named Main.
  • public static void main(String[] args): The entry point of the program.
  • System.out.println: Prints text to the console.

This is the traditional starting point for all Java programs.

← PrevNext →