.println()

StevenSwiniarski's avatar
Published Jun 25, 2022Updated Nov 5, 2022
Contribute to Docs

The .println() method prints its argument to the console followed by a new line. It is probably the most common method of displaying output to the console.

Syntax

System.out.println(argument);

The argument will be displayed on the console, followed by a new line.

Example

The following example prints some content to the console.

public class PrintExample {
public static void main(String[] args) {
System.out.println("Output");
System.out.println(123.456);
System.out.println(true);
}
}

This results in the output:

Output
123.456
true

All contributors

Contribute to Docs

Learn Java on Codecademy