Does the while loop print \n automatic after any one of the loops ? What should we do to not print that \n ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Does the while loop print \n automatic after any one of the loops ? What should we do to not print that \n ?

31st Jan 2018, 11:08 AM
K e V i N
K e V i N - avatar
2 Answers
+ 3
System.out.print(prints & stays on the same line); System.out.println(prints & moves to next line); if theres a print statement inside of the loop body it will be executed each loop if theres a print statement outside of the loop body it will be executed once the loop finishes. for(){this is the body of the for loop}
31st Jan 2018, 11:51 AM
D_Stark
D_Stark - avatar
+ 12
no , u will not get \n after each cycle of loop /* for getting next line after every loop ... u can do*/ while(condition){ //statement(s); System.out.println (""); //last statement of loop }
31st Jan 2018, 11:46 AM
Gaurav Agrawal
Gaurav Agrawal - avatar