.println()

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

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Java on Codecademy