Relational Operators in Java


☞They are binary operators.

☞They are used to compare two expressions and results in true or false.

☞Following are the types of relational operators in java.

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

☞Precedence of relational operators.

< <= > >=        
== != 

Example

public class RelationalExample {
    public static void main(String[] args) {
        
        System.out.println(5<7);
        System.out.println(5<=7);
        System.out.println(5>7);
        System.out.println(5>=7);
        System.out.println(5==7);
        System.out.println(5!=7);
    
    }
}

Output

true
true
false
false
false
true