...
This compliant solution mitigates the problem by using &, which guarantees that both i1 and i2 are incremented regardless of the outcome of the first condition:
| Code Block | ||
|---|---|---|
| ||
public void exampleFuntion() { while (++i1 < array1.length & // Not && ++i2 < array2.length && array1[i1] == array2[i2]){ //doSomething } } |
Applicability
Failure to understand the behavior of the bitwise and conditional operators can cause unintended program behavior.
...