Computer Science, asked by Atharva2124, 1 year ago

what is difference between print and print on in java

Answers

Answered by kreetikagupta
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.......

kreetikagupta: hmm
Atharva2124: Which college
kreetikagupta: in school not college
Atharva2124: which
kreetikagupta: srvs
kreetikagupta: and you
Atharva2124: I am in college shau vidaylay
kreetikagupta: ohk
kreetikagupta: mark as brainliest
Atharva2124: what are you going to become
Similar questions