Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Difference Between print() and println() in Java

In this article, you can find two concepts discussed: print() and println() in Java. Here, we have discussed the definition for the two terms, and it’s comparison and differences. By knowing the differences, candidates will not only understand the topics, but will also find it easy to get good marks.

Now, the two topics under discussion in the article are:

  • print()
  • println() in Java

What is print() ?

The print() is a method in Java, and it displays a text on the console, which is considered the parameter to this method in the form of String. This method also enables printing the text on the console, and the cursor remains at the end of the text on the console. The next printing occurs from just here. This method functions only if there is an argument.

What is println() in Java ?

A println() in Java is also utilised to display a text on the console, which is the parameter to this method in String. This method also enables printing the text on the console, and the cursor remains at the start of the following line at the console. The next printing occurs from the next line, in this. This method is operable even without an argument.

Difference Between print() and println() in Java

print() println() in Java
Does not add any new line Adds a new line after message is displayed
Printing begins in the same line Printing begins in the next line
Compatible only with argument operations, or else it’s a syntax error Is operable with arguments

Keep learning and stay tuned to BYJU’S to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2024, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cutoff, GATE Previous Year Question Paper, and more.

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*