print vs println in Java

Last Updated : 11 Jun, 2026

In Java, print() and println() are methods of the PrintStream class used to display output on the console. Both methods print data such as strings, numbers, characters, and objects, but they differ in how they handle the cursor position after printing. Understanding their difference is important for formatting console output correctly.

  • print() displays output and keeps the cursor on the same line.
  • println() displays output and moves the cursor to the next line.
  • Both methods are commonly used with System.out.

print() method in Java is used to display a text on the console. This text is passed as the parameter to this method in the form of String. This method prints the text on the console and the cursor remains at the end of the text at the console.

  • Prints output on the console.
  • Cursor remains at the end of the printed text.
Java
import java.io.*;

class GFG {
    public static void main(String[] args)
    {

        // The cursor will remain
        // just after the 1
        System.out.print("GfG1");

        // This will be printed
        // just after the GfG2
        System.out.print("Gf2");
    }
}

Output
GfG1GfG2

println() Method

println() method in Java is also used to display a text on the console. This text is passed as the parameter to this method in the form of String. This method prints the text on the console and the cursor remains at the start of the next line at the console.

  • Can be called with or without arguments.
  • Helps improve output readability.
Java
import java.io.*;

class GFG {
    public static void main(String[] args)
    {

        // The cursor will after GFG1
        // will at the start
        // of the next line
        System.out.println("GfG1");

        // This will be printed at the
        // start of the next line
        System.out.println("GfG2");
    }
}

Output
GfG1
GfG2

Example Demonstrating Both Methods

Java
public class Main {
    public static void main(String[] args) {

        System.out.print("Hello");
        System.out.println(" Java");

        System.out.print("Welcome");
        System.out.println(" Developers");
    }
}

Output
Hello Java
Welcome Developers

print() Vs println()

Featureprint()println()
Line BreakDoes not add a new lineAdds a new line after printing
Cursor PositionRemains at end of current lineMoves to beginning of next line
Empty CallNot allowedAllowed (println())
Output FormatContinuous outputSeparate line output
ReadabilityLess readable for multiple outputsMore readable
UsageSame-line printingLine-by-line printing
SyntaxSystem.out.print(data);System.out.println(data);
Newline CharacterNot insertedAutomatically inserted
Common Use CaseMenus, formatted text, inline outputMessages, results, reports
Return Typevoidvoid
Comment