0
Why this problem print 1234, then infinite loop?
int a = 1; while(a <= 10){ if(a % 5 == 0) continue; else System.out.print(a); a++; }
2 Antworten
+ 1
It is because when 'a' becomes 5, continue is executed and it moves back to the while condition and 'a' is never incremented. So the if condition is always true.
0
5 % 5 == 0
continue loop
after it variable a never increase