0
What is the difference between " print" and " println" (in Java)?
6 ответов
0
Lets look at an example:
1) System.out.print ("Hello");
2) System.out.print ("World");
This will give the following output:
********************
HelloWorld
********************
But if you use the "println" function:
1) System.out.println ("Hello");
2) System.out.println ("World");
Your output slightly changes:
********************
Hello
World
********************
+ 2
Mirielle print function is also available in java
+ 2
println() method prints the output and moves the cursor to the next line.
Whereas print() just prints the output and the cursor remains on the same line.
+ 2
print() and println() method will do the same thing but in println() value will print on console and cursor will go on new line. As you see there is ln with print which is new line.