0
class MyClass { public static void main(String[ ] args) { boolean b = true ; for (int i = 0;i<10;i++) if (b=!b)
expain this plzzz
2 Respuestas
0
b=!b changes (flips) the boolean value of b in every iteration.
first, b's value was 1. so in first iteration, !b is 0. that makes b=!b equivalent to b=0.
same way, in next iteration, b=!b becomes b=1.
so in that code, if-condition is met in every odd value of i.
0
thank you