Hello World in Java

One println inside main. If this runs, javac worked.

BeginnerModule 1: Basic Java ProgramsExample 1 of 20
hello-world.java
1public class Main {
2 public static void main(String[] args) {
3 System.out.println("Hello, World!");
4 }
5}

Output

Hello, World!

What's going on

The class name is Main because the file is Main.java. Mismatch and javac refuses.

public static void main(String[] args) is the entry. Miss static and the JVM has nothing to call.

System.out.println adds a newline. print does not. Quotes make a string. Drop them and Java looks for a variable named Hello.