print and println in Java

The print() and println() methods in Java are used to print text on the console for the user to see. Both of these methods are identical in terms of functionality except for one minor difference that will be highlighted below. But first, let’s have a look at each function individually.

svg viewer

1 . print()

The print() method has various overloaded forms that take different data types as parameters; hence, the print() method can print strings, integers, floats, objects, and other supported data types in Java.

print() keeps the cursor at the end of the text after printing; the next print takes place from there.

class PrintDemo {
public static void main( String args[] ) {
System.out.print("Hello! ");
System.out.print("I work at Educative.");
}
}

2 . println()

println() has the same overloaded forms as print() and is, thus, able to deal with several supported data types. println() is only different from print() in the way that println() shifts the cursor on the console to the beginning of the next line when it is done printing. This is why, in println(), the subsequent print is printed in the next line. Have a look at the difference below:

class PrintlnDemo {
public static void main( String args[] ) {
System.out.println("Hello! ");
System.out.println("I work at Educative.");
}
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved