Java .println()

garanews'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.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours

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

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours