The main() Method
A free lesson from Swipe Coding · Java, level 1 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Every Java program needs a starting point — a place where execution begins. This starting point is one very specific method called main(). When you start a Java program, the Java Virtual Machine (JVM) automatically looks for this method.
public class Main {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}The line "public static void main(String[] args)" is called the method's signature. Each word has a fixed meaning: "public" makes the method callable from outside, "static" means it belongs to the class itself (you don't need an object to start it), "void" means the method doesn't return a value, "main" is the fixed name the JVM looks for, and "(String[] args)" is a place for text arguments at program start — the parentheses must be there even if you don't use them.
public static void main(String[] args) {
}What does the JVM look for to start a Java program?
If the signature isn't exactly right — for example wrong capitalization like "Main" instead of "main", or a missing word — the JVM won't recognize the method as the starting point. The program then can't be started.
For the JVM to start a program, it looks for a method called ____.
In Java, the main() method must always read exactly "public static void main(String[] args)".
Inside the main() method, you write your program's actual statements — they are executed step by step, in the order they appear. We'll take a closer look at exactly what a "statement" is in the next lesson.
What does the keyword "void" mean in the main() method?
Keep your streak going in Swipe Coding
Swipe through every level of Java on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →