0

What is the difference between " print" and " println" (in Java)?

1st Dec 2019, 10:27 AM
Sandesh Raj
Sandesh Raj - avatar
6 odpowiedzi
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 ********************
2nd Dec 2019, 5:13 PM
🇲​🇴​🇭​🇦​🇲​🇲​🇦​🇩​ 🇯​🇮​🇱​🇦​🇳​
🇲​🇴​🇭​🇦​🇲​🇲​🇦​🇩​ 🇯​🇮​🇱​🇦​🇳​ - avatar
+ 2
Mirielle print function is also available in java
1st Dec 2019, 10:33 AM
Sandesh Raj
Sandesh Raj - avatar
+ 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.
1st Dec 2019, 10:35 AM
Avinesh
Avinesh - avatar
+ 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.
1st Dec 2019, 10:46 AM
A͢J
A͢J - avatar