Slide 1
Slide 2
Slide 3

Relational Operators in java programming (V18)

No Comments

Relational Operators

Relational operators in Java are used to compare two values.
They return a boolean value (true or false) based on the comparison.

List of Relational Operators in Java:

Operator Description Example (a = 10, b = 20) Result
== Equal to a == b false
!= Not equal to a != b true
> Greater than a > b false
< Less than a < b true
>= Greater than or equal to a >= b false
<= Less than or equal to a <= b true

Source Code:

Copied!
public class RelationalOperators {
    public static void main(String[] args) {
        int a = 10, b = 20;
        
        System.out.println("a == b: " + (a == b));  // false
        System.out.println("a != b: " + (a != b));  // true
        System.out.println("a > b: " + (a > b));    // false
        System.out.println("a < b: " + (a < b));    // true
        System.out.println("a >= b: " + (a >= b));  // false
        System.out.println("a <= b: " + (a <= b));  // true
    }
}

Result:

Watch the video:


Ebook: https://softkhpc.blogspot.com/2025/05/java-programming-ebooks.html

back to top