Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Java Program Structure · Lesson 12 of 28

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 exactly one starting line — this is it. 🚀

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!");
    }
}
As soon as you start this program, the JVM finds the main() method and begins execution right there.

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) {

}
This exact line is what the JVM expects as a program's starting point.
Quick check

What does the JVM look for to start a Java program?

🤖
Even one wrong letter here and the JVM will not find your 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.

Fill in the blank

For the JVM to start a program, it looks for a method called ____.

True or false

In Java, the main() method must always read exactly "public static void main(String[] args)".

🤖
Next up: what exactly counts as a 'statement' in Java. ➡️

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.

Quick check

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 →