System.out.println in Java
Last Updated :
13 Mar, 2025
Java System.out.println() is used to print an argument that is passed to it.
Parts of System.out.println()
The statement can be broken into 3 parts which can be understood separately:
- System: It is a final class defined in the java.lang package.
- out: This is an instance of PrintStream type, which is a public and static member field of the System class.
- println(): As all instances of the PrintStream class have a public method println(), we can invoke the same on out as well. This is an upgraded version of print(). It prints any argument passed to it and adds a new line to the output. We can assume that System.out represents the Standard Output Stream.

Syntax:
System.out.println(parameter)
Parameters: The parameter might be anything that the user wishes to print on the output screen.
Example of Java System.out.println()
Example 1:
Below is the implementation of System.out.println :
Java
// Java code to illustrate
// System.out.println();
import java.io.*;
// Driver Class
class GFG {
// main function
public static void main(String[] args)
{
System.out.println("Welcome");
System.out.println("To");
System.out.println("GeeksforGeeks");
}
}
OutputWelcome
To
GeeksforGeeks
Example 2:
Below is the implementation of System.out.println :
Java
// Java code to illustrate
// System.out.println();
import java.io.*;
// Driver Class
class GFG {
// main function
public static void main(String[] args)
{
// Declaring variable
int num1 = 10, num2 = 20, sum;
// Printing the variables
System.out.print("The addition of ");
System.out.print(
num1 + " and " + num2 + " is: ");
// Printing the result after operation
System.out.println(num1 + num2);
}
}
OutputThe addition of 10 and 20 is: 30
Just like System.out, Java provides us with two other standard or default input-output streams:
- System.in: This is the standard input stream that is used to read characters from the keyboard or any other standard input device. Example:
InputStreamReader inp = new InputStreamReader(System.in);
- System.err: This is the standard error stream that is used to output all the error data that a program might throw, on a computer screen or any standard output device.
Example:System.err.print("Error");
Overloads of println() method
As we know, Method Overloading in Java allows different methods to have the same name, but different signatures or parameters where each signature can differ by the number of input parameters or type of input parameters or both. From the use of println() we observed that it is a single method of PrintStream class that allows the users to print various types of elements by accepting different type and number of parameters.
For example:
System.out.println(),
System.out.println(int),
System.out.println(double),
System.out.println(string),
System.out.println(character),
etc.
PrintStream has around 10 different overloads of println() method that are invoked based on the type of parameters passed by the user.
Example:
Java
// Java code to illustrate method
// overloading in println()
import java.io.*;
// Driver Class
class PrintLN {
// main function
public static void main(String[] args)
{
// Declaring different datatypes
int num = 10;
char ch = 'G';
String str = "GeeksforGeeks";
double d = 10.2;
float f = 13.5f;
boolean bool = true;
// Various overloads of println() method
System.out.println();
System.out.println(num);
System.out.println(ch);
System.out.println(str);
System.out.println(d);
System.out.println(f);
System.out.println(bool);
System.out.println("Hello");
}
}
Output10
G
GeeksforGeeks
10.2
13.5
true
Hello
System.out.print()
This method prints the text on the console and the cursor remains at the end of the text at the console. The next printing takes place from just here. This method must take at least one parameter else it will throw an error.
System.out.println()
This method prints the text on the console and the cursor remains at the start of the next line at the console. The next printing takes place from the next line. This method may or may not take any parameter.
Example:
Java
// Java code to illustrate difference
// between print() and println()
import java.io.*;
// Driver Class
class Demo_print {
// main function
public static void main(String[] args)
{
System.out.println("Using print()");
// using print()
// all are printed in the
// same line
System.out.print("GfG! ");
System.out.print("GfG! ");
System.out.print("GfG! ");
System.out.println();
System.out.println();
System.out.println("Using println()");
// using println()
// all are printed in the
// different line
System.out.println("GfG! ");
System.out.println("GfG! ");
System.out.println("GfG! ");
}
}
Output:
Using print()
GfG! GfG! GfG!
Using println()
GfG!
GfG!
GfG!
Performance Analysis of System.out.println()
println() is a method that helps display output on a console. This might be dependent on various factors that drive the performance of this method. The message passed using println() is passed to the server's console where kernel time is required to execute the task. Kernel time refers to the CPU time. Since println() is a synchronized method, so when multiple threads are passed could lead to the low-performance issue. System.out.println() is a slow operation as it incurs heavy overhead on the machine compared to most IO operations. There is an alternative way of performing output operations by invoking PrintWriter or the BufferedWriter class. They are fast as compared to the println() of the PrintStream class.
Related Articles:
- Difference between print() and println()
- Input-Output in Java
- PrintStream println() method in Java with Examples
- Redirecting System.out.println() output to a file in Java
Similar Reads
Java Tutorial Java is a high-level, object-oriented programming language used to build web apps, mobile applications, and enterprise software systems. It is known for its Write Once, Run Anywhere capability, which means code written in Java can run on any device that supports the Java Virtual Machine (JVM).Java s
10 min read
Java OOP(Object Oriented Programming) Concepts Java Object-Oriented Programming (OOPs) is a fundamental concept in Java that every developer must understand. It allows developers to structure code using classes and objects, making it more modular, reusable, and scalable.The core idea of OOPs is to bind data and the functions that operate on it,
13 min read
Java Interview Questions and Answers Java is one of the most popular programming languages in the world, known for its versatility, portability, and wide range of applications. Java is the most used language in top companies such as Uber, Airbnb, Google, Netflix, Instagram, Spotify, Amazon, and many more because of its features and per
15+ min read
SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e
7 min read
Arrays in Java Arrays in Java are one of the most fundamental data structures that allow us to store multiple values of the same type in a single variable. They are useful for storing and managing collections of data. Arrays in Java are objects, which makes them work differently from arrays in C/C++ in terms of me
15+ min read
TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While
7 min read
Collections in Java Any group of individual objects that are represented as a single unit is known as a Java Collection of Objects. In Java, a separate framework named the "Collection Framework" has been defined in JDK 1.2 which holds all the Java Collection Classes and Interface in it. In Java, the Collection interfac
15+ min read
Inheritance in Java Java Inheritance is a fundamental concept in OOP(Object-Oriented Programming). It is the mechanism in Java by which one class is allowed to inherit the features(fields and methods) of another class. In Java, Inheritance means creating new classes based on existing ones. A class that inherits from an
13 min read
Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br
14 min read
Java Exception Handling Exception handling in Java allows developers to manage runtime errors effectively by using mechanisms like try-catch block, finally block, throwing Exceptions, Custom Exception handling, etc. An Exception is an unwanted or unexpected event that occurs during the execution of a program, i.e., at runt
10 min read