+ 1

for(;;) { int i=0; if(i==1){System.out.println(i); break;} ++i;} Will this code run for infinite times? If yes then how?

This is regarding for loop. I want to know how iteration occurs in this case

13th Aug 2017, 7:11 AM
Paul Gaikwad
Paul Gaikwad - avatar
1 ответ
0
it will run infine amount of times cause in the loop you declare 'i' and assifn 0 to it. later you check if it is equal 1 but it is not. next you say "i want i to be 1 now". and then you go back and override 'i with a number of 0
13th Aug 2017, 8:05 AM
Paul