System.out.println()
A free lesson from Swipe Coding · Java, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
To display anything on the screen (the "console") in Java, you need the command System.out.println(). It outputs the text that you pass to it in parentheses and quotation marks.
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}The "ln" in println stands for "line". After the output, the cursor automatically jumps to a new line. So the next text begins below it, not right after it.
System.out.println("First line");
System.out.println("Second line");
// Output:
// First line
// Second lineSystem.out.println() outputs text and then automatically jumps to a new ____.
System.out is the destination of the output (the console). println is the method name. The text in parentheses and in double quotation marks is called a "String" — exactly what gets printed.
System.out.println("I am learning Java.");
System.out.println("This is fun!");
// Output:
// I am learning Java.
// This is fun!What happens after System.out.println("Hi"); outputs the text?
Important: The text that println() should output must be in double quotation marks, for example "Hello". Without quotation marks, Java would interpret the text as program code rather than plain text.
System.out.println() outputs text without any line break, just like System.out.print().
Keep your streak going in Swipe Coding
Swipe through every level of Java on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →