println() are two methods used to output data to the console or other output streams. The main difference between them is that
println() method adds a newline character
\n at the end of the output, whereas
print() method doesn't.
Here's an example to illustrate the difference:
System.out.print("Hello, "); System.out.print("World!");
System.out.println("Hello, "); System.out.println("World!");
As you can see, the first example outputs both strings on the same line without any separation. The second example outputs each string on a separate line with a newline character added at the end of each string.
In summary, if you want to output text on the same line without any separation, use the
print() method. If you want to output text on a new line, use the