The result of certain comparison tests can sometimes be inferred from their context and the results of other comparisons. This can be an indication of faulty logic and may result in dead code or infinite loops if, for example, a loop condition never changes its value.

Inspect the code to check whether the logic is correct, and consider simplifying the logical expression.

In the following example the final test on x will always be true, and thus the condition is redundant and potentially wrong. If the "do more stuff" part is intended to always execute after the loop then the condition should be removed to make this clear.

  • Java Language Specification: The if Statement.