i == 10 | EqualCondition |
i != 10 | NotEqualCondition |
i < 10 | LessThanCondition |
i <= 10 | LessOrEqualCondition |
i > 10 | GreaterThanCondition |
i >= 10 | GreaterOrEqualCondition |
When used as the loop test inside a for loop, these expressions evaluate the same way as when they are used inside an if statement because the evaluation model code behind the expressions is the same, regardless of the statement type and context:
for (int i = 10; i != 10; i--) { ... } if (i != 10) { ... }In both examples above, the i != 10 expression compiles to an instance of NotEqualCondition whose evaluate() method compares the value of the "i" variable to the value on the right side of the expression, and returns true if they are not equal.
No comments:
Post a Comment