Start Coding Now

Difference between print() and println() in Java

Learn when to use System.out.print() vs System.out.println() and how to format output effectively.

System.out.print()

Prints text without creating a new line at the end. cursor stays on the same line.

System.out.println()

Prints text and moves the cursor to the new line (ln = line).

Example

System.out.print("Hello");
System.out.print("World");
// Output: HelloWorld

System.out.println("Hello"); System.out.println("World"); // Output: // Hello // World

Frequently Asked Questions