| Operator and Expression |
| |
| Relational Integer Operators |
| |
The last group of integer operators is the relational operators, which all operate on
integers but return a type boolean. Lists of the relational integer operators. |
| |
| The relational integer operators. |
| |
|
|
|
|
|
Description |
Operator |
| Less-than |
< |
| Greater-than |
> |
| Less-than-or-equal-to |
<= |
| Greater-than-or-equal-to |
>= |
| Equal-to |
== |
| Not-equal-to |
!= |
|
| |
| These operators all perform comparisons between integers. |
| |
| The Relational class |
| |
class Relational
{
public static void main (String args[])
{
int x = 7, y = 11, z = 11;
System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("z = " + z);
System.out.println("x < y = " + (x < y));
System.out.println("x > z = " + (x > z));
System.out.println("y <= z = " + (y <= z));
System.out.println("x >= y = " + (x >= y));
System.out.println("y == z = " + (y == z));
System.out.println("x != y = " + (x != z));
}
} |
|
| |
| The output of running Relational follows: |
| |
x= 7
y = 11
z = 11
x < y = true
x > z = false
y <= z = true
x >= y = false
y == z = true
x != y = true |
|
|
| |
| |
|
| |
| |