### 3.10. Equality

#### Primitive Data Value Equality: `==`, `!=`

Given that `a` and `b` represent operands of primitive data types, the primitive data value equality operators are defined as shown in Table 3.7.

Table 3.7. Primitive Data Value Equality Operators`a == b` | `a` and `b` are equal? That is, have the same primitive value? (Equality) |

`a != b` | `a` and `b` are not equal? That is, do not have the same primitive value? (Inequality) |

The equality operator `==` and the inequality operator `!=` can be used to compare primitive data values, including `boolean` values. Binary numeric promotion is applied to the nonboolean operands of these equality operators.

int year = 2002; boolean isEven = year % 2 == 0; // true. boolean compare = '1' == 1; // false. Binary numeric promotion applied. ...