Java Hello World Program

Let's write, compile and run the simplest Java program, and understand every word in it.

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

Understanding the Program

KeywordMeaning
classDeclares a class. Every Java program has at least one.
publicAccess modifier: visible to everyone, so the JVM can call main.
staticLets main run without creating an object.
voidmain returns nothing.
mainEntry point of the program.
String[] argsCommand-line arguments.
System.out.println()Prints text followed by a new line.
Common mistakeJava is case-sensitive. system.out.println or Main vs main will cause errors.

Quick Check

Which method is the entry point of a Java program?

Track your progress through the Java course