Java Relational Operators

Introduction

The relational operators determine equality and ordering.

The relational operators are shown here:

Operator Result
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

The outcome of Java Relational operations is a boolean value.

Java type, including integers, floating-point numbers, characters, and Booleans can be compared using the equality test, ==, and the inequality test, !=.

Java equality is denoted with two equal signs, not one.

A single equal sign is the assignment operator.

Only numeric types, integer, floating-point, and character, can be compared using the ordering operators.

For example, the following code fragment is valid expression:

int a = 4;  
int b = 1;  
boolean c = a < b; 



PreviousNext

Related