+ 1

How to print this in java ? 15 10 15 10 15 10 15 10........

22nd Apr 2018, 1:55 PM
ChittranshiSaraswat
2 ответов
+ 4
for (int i = 0; i < 10; i++) { System.out.print("15 10 "); } Will do it 10 times while (true) { System.out.print("15 10 "); } To do it infinitely
22nd Apr 2018, 1:58 PM
TurtleShell
TurtleShell - avatar
+ 1
More generally if you want to switch between doing two different tasks you can use a boolean value like shown below boolean flip = true; while (condition){ if (flip) //execute task 1 else //execute task 2 flip = !flip; }
22nd Apr 2018, 5:09 PM
cyk
cyk - avatar