Basic Comparisons

In this lesson, we will compare two primitives that have the same type, and then discuss how to compare two objects.

Comparing primitives

When comparing primitives, as in the previous examples, we use operators such as == or <. These operators are examples of relational operators. The figure given below lists these operators and their meanings. Notice the two-character operators <= and >=. These exist because characters such as and are not on standard keyboards.

Get hands-on with 1200+ tech skills courses.