Printing Output

Console output is the quickest way to see what a program is doing. Java provides print and println through System.out.

print leaves the cursor on the current line. println prints its value and then starts a new line. That small difference lets several calls build one readable line.

print versus println

public class Main {
    public static void main(String[] args) {
        System.out.print("Status: ");
        System.out.println("Online");
        System.out.println("Mode: Training");
    }
}

Output:

Status: Online
Mode: Training

The first two calls join into Status: Online. The final println begins and finishes the next line.

Spaces inside string quotes are real output. Java does not insert a space between separate print calls.

Print a race announcement in the exercise below. You will need both print and println.