Hello World! · Java

Ch 2 · Your First Java Program — card 1 of 2.

Every Java program lives inside a class, and starts running from a special method called main. This structure is required — Java is strict about it. Inside main, we use System.out.println(...) to print a line of text to the screen. Notice every statement ends with a semicolon ; — in Java that is required, like a full stop at the end of a sentence.

public class Main {
    public static void main(String[] args) {
        // println prints a line of text
        System.out.println("Hello, World! 🚀");
        System.out.println("Welcome to Java!");
    }
}