Monday, May 30, 2016

Filled Under:

Difference between println() and print() in java

Share

This is a very useful thing when you are doing some fancy programming in java and want to decorate your output.


println() and print() have same functionality of printing strings inside () with a few difference.

Both are from same parents(System.out):

for println=>System.out.println("Hello I am Print");

for print =>System.out.print("Hello I am Print");


Now the difference between println() and print() is

PRINTLN:


  • println() means print with a new line. Or get a new line then print the out put.
  • automatic new line before printing.
PRINT
  • print() means just start printing no matter where you are. No new line generated.
  • you need to insert new line manually.

Best thing about them is Java happily support both of them.

0 comments:

Post a Comment