Relational Operators of JAVA


Relational Operators of JAVA

Whenever we want to evaluate the effects of two expressions or operands in a program, relational operators are used to identify whether the operand is equal to, no longer equal to, greater than, much less than, any other operand. The table below lists each type of equality and relational operator.

Operator Symbol

Name of the Operator

Example

Operation

==

Equal

a1==b1

a1 is Equal To b1

!=

Not Equal To

a1!=b1

a1 is not Equal To b1

> 

Greater than

a1>b1

a1 is greater than To b1

< 

Less than

a1<b1

a1 is less than  To b1

>=

greater than or Equal To

a1>=b1

a1 is greater than or Equal To b1

<=

Less than or Equal To

a1<=b1

a1 is Less than or Equal To b1

The Syntax and example of Relational Operators is given below.

Syntax:

expression1 Operator expression2

Example:

int marks=55

if(marks>=35)

{

                System.out.println("Pass");

}

else

{

                  System.out.println("Fail");

}

 

Post a Comment

0 Comments