A brief analysis of the difference between print and println in Java

  • 2020-04-01 02:08:49
  • OfStack

The print() method finishes the operation after printing the string specified in the parenthesis, instead of adding the return, the cursor stays to the right of the last character in the string, println() adds the return, and the cursor stops on the next line.

For (I = 1; I< 6; I++)
Println (I);
Results:
1
2
3
4
5

For (I = 1; I< 6; I++)
  Print (I);
Results: 12345

"Ln" is shorthand for "line" minus the vowels


Related articles: