
5.1 Forming Conditions 209
TABLE 5.1 Equality Operators
Equality Operator Type Meaning
== binary is equal to
!= binary is not equal to
Java provides equality, relational, and logical operators to evaluate and test
whether an expression is true or false. It also provides selection statements
to transfer control to a different part of the program depending on the
result of that test.
5.1.1 Equality Operators
A common operation is to compare two variables or values of the same
data type to determine if their values are equal. For example, we need to
compare the user’s input to a ‘y’ to determine whether he or she wants to
play again. Or if we want to print ...