Course contentsShow
← Java
Lesson 16 of 2,8701. Java Setup and First ProgramFree lesson

The System.out.println Method

Exploring System.out.println for console output, including printing strings and multiple lines.

The System.out.println Method

You'll learn how to display text and information in the console using Java's primary output method.

When you wrote your first Hello World program, you used System.out.println to show text on the screen. Now let's understand what's actually happening when you use this command.

What System.out.println Does

Think of System.out.println as Java's way of speaking to you through the console window. It takes whatever you put inside the parentheses and displays it as output, then automatically moves to a new line (that's what the "ln" stands for—"line").

The basic structure looks like this:

System.out.println("Hello, World!");

Printing Strings

When you want to print text (called a string in programming), you wrap it in double quotes:

System.out.println("Welcome to Java programming");
System.out.println("This is my first program");

Printing Multiple Lines

You can call System.out.println multiple times to display several lines of output:

public class MultiLineDemo {
    public static void main(String[] args) {
        System.out.println("Line 1");
        System.out.println("Line 2");
        System.out.println("Line 3");
    }
}

Each call creates a new line automatically, so your output appears stacked vertically in the console.

Why the Odd Name?

The name breaks down like this: System is a built-in Java class, out represents the standard output stream (your console), and println is the method that prints with a line break. You'll understand these parts more deeply later—for now, just memorize this as your "talk to the console" command.

Key Takeaway: System.out.println is your primary tool for displaying text in the console; put text in double quotes inside the parentheses, and each call automatically creates a new line.