what is difference between print and print on in java
Answers
Answered by
2
Both methods are used to print data on console, the only difference between above two methods is 'System.out.println' prints data and place the cursor in next line. So the next coming output prints in the next line whereas 'System.out.print' prints data and place the cursor in the same line. So the next coming output prints in the same line.
Let us take an example
for(int i = 0; i < 5; i++) System.out.print(" " + i);
The above code generates the following output
0 1 2 3 4
for(int i = 0; i < 5; i++) System.out.println(" " + i); The above code generates the following output
0
1
2
3
4
hope it helpful.......
Let us take an example
for(int i = 0; i < 5; i++) System.out.print(" " + i);
The above code generates the following output
0 1 2 3 4
for(int i = 0; i < 5; i++) System.out.println(" " + i); The above code generates the following output
0
1
2
3
4
hope it helpful.......
kreetikagupta:
hmm
Similar questions
English,
8 months ago
Social Sciences,
8 months ago
English,
8 months ago
Math,
1 year ago
Math,
1 year ago