Java Hello World Program
Let's write, compile and run the simplest Java program, and understand every word in it.
class Simple {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Hello World
Understanding the Program
| Keyword | Meaning |
|---|---|
class | Declares a class. Every Java program has at least one. |
public | Access modifier: visible to everyone, so the JVM can call main. |
static | Lets main run without creating an object. |
void | main returns nothing. |
main | Entry point of the program. |
String[] args | Command-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