O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 == ba and b are equal? That is, have the same primitive value? (Equality)
a != ba 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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required