Module 1: Start Coding in Java
Hello World Explained Line by Line
Read the classic Java starter program carefully so every piece of the class and `main` method makes sense.
Author
Java Learner Editorial Team
Reviewer
Technical review by Java Learner
Last reviewed
2026-04-16
Java version
Java 25 LTS
Learning goals
- Recognize the role of a class in a simple Java file
- Identify the `main` method as the entry point
- Understand what `System.out.println` does
The class: public class Main creates a class named Main. In beginner Java, your code lives inside a class, and the file name usually matches the public class name.
The main method: public static void main(String[] args) is the standard entry point. When Java starts your simple program, it looks for this method.
Printing text: System.out.println(...) sends text to the console. println adds a new line after printing.
Why this matters: Once you can read this tiny program comfortably, you can begin changing values, adding variables, and combining multiple statements.
Runnable examples
The smallest useful program
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}Expected output
Hello, world!
Two print lines in one main method
public class Main {
public static void main(String[] args) {
System.out.println("Line one");
System.out.println("Line two");
}
}Expected output
Line one Line two
Common mistakes
Using single quotes around a full sentence
Use double quotes for strings, such as `"Hello"`.
Forgetting the semicolon at the end of `println`
Java statements normally end with `;`.
Mini exercise
Add one more `println` call that prints the current Java module you are on.
Summary
- A simple Java program has a class and a `main` method.
- `System.out.println` prints output to the console.
- File structure matters even for small programs.
Next step
After you can read Hello World, set up JDK 25 locally so you can run programs outside the browser too.
Sources used