[Solved] Java For loop Issue in condition statement


Condition to iterate your loop

for(int j=0; j<=99 & a[j] > 1; j++)

is j<=99 & a[j].

You initialized j to 0, so j<=99 part is true, but problem lies in second part of this condition.
For j=0 condition a[j]>1 becomes a[0]>1, but a[0] is -2, which leaves us with -2>1 which is false.

So we end up with true & false which is false, so your loop will no longer iterate (or to be more precise will not even start iterating).

1

solved Java For loop Issue in condition statement