System.out.println()
The classic way to print to the console: prints a value and ends the line.
Available since: Java 1.0
Syntax
public void println(Object x)Parameters
| Parameter | Type | Description |
|---|---|---|
| x | Object / String / int / … | A value of any type. Without an argument, an empty line. |
Return value
voidNothing.
Examples
Same as IO.println(); print() does not end the line:
void main() {
System.out.println("Hello");
System.out.print("A");
System.out.print("B");
System.out.println();
System.out.println(3.14);
}Output:
Hello
AB
3.14Notes
System.out is a PrintStream object, the standard output stream. Error messages go to System.err: they look the same in the console but can be redirected separately. The classic class with public static void main(String[] args) uses exactly this form; in Java 25 it can be replaced with IO.println().
See also
- IO.println() — Prints a value to the console and ends the line.
- System.out.printf() — Prints a string built from a template with %s, %d, %.2f placeholders.
- IO.print() — Prints a value to the console without ending the line.
In the tutorial
- Your first program — The parts of a Java program: the main method, statements, output with IO.println, comments and the classic form with public class Main.