When applied to primitive data types, the comparison operators return a value of type boolean.
== | equal to (Attention: = is different from == ) |
!= | different from |
> | greater than |
< | less than |
>= | greater than or equal to |
<= | less than or equal to |
Example:
10 < 20 | is a boolean expression equivalent to | true |
10 == 20 | is a boolean expression equivalent to | false |
10 != 20 | is a boolean expression equivalent to | true |
Example:
boolean x = 10 < 20; // assignment of the value of a boolean expression System.out.println(x); // prints "true"