+ 1

What's the difference between these?

int y = 15; while(y > 0) { System.out.println(y); y--; } and this for(int x = 15; x > 0; x--) { System.out.println(x) }

17th Jun 2020, 9:54 AM
i changed my name cuz it was cringe
i changed my name cuz it was cringe - avatar
3 RĂ©ponses
0
i changed my name cuz it was cringe One main difference is for loop use for fix iteration.
17th Jun 2020, 11:55 AM
AÍąJ
AÍąJ - avatar
+ 2
There is no difference, from there you can see how write one problem with 2or more cycles (for, while, do while) Also you write this example with do while, and use which is better for you
17th Jun 2020, 9:57 AM
ê§àŒ’â˜ŹBad☏Boyâ˜ŹàŒ’ê§‚
ê§àŒ’â˜ŹBad☏Boyâ˜ŹàŒ’ê§‚ - avatar
+ 2
There is no difference In the first: state u use while loop In the second :state u use for loop
17th Jun 2020, 9:57 AM
Muhammad Galhoum
Muhammad Galhoum - avatar