A.8. Decision Making: Equality and Relational Operators
A condition is an expression that can be true or false. This section introduces Java’s if selection statement, which allows a program to make a decision based on a condition’s value. For example, the condition “grade is greater than or equal to 60” determines whether a student passed a test. If the condition in an
if statement is true, the body of the
if statement executes. If the condition is false, the body does not execute. We’ll see an example shortly.
if statements can be formed by using the equality operators (== and !=) and relational operators (>, <, >= and <=) summarized in Fig. A.14. Both equality operators have the same level of precedence, which is lower than that ...