Comparison Operators 
Operators explained 
Here are the most common comparison operators in Java:
| Usage | Description | 
|---|---|
| a > b | Is agreater thanb? | 
| a >= b | Is agreater than or equal tob? | 
| a < b | Is aless thanb? | 
| a <= b | Is aless than or equal tob? | 
| a == b | Is aequal tob? | 
| a != b | Is anot equal tob? | 
TIP
In Java, == checks for equality of primitive types and object references. For object content equality, use .equals().
Examples 
Using inequalities 
java
public class Main {
    public static void main(String[] args) {
        int minimumAge = 18;
        int userAge = 21;
        System.out.println(userAge >= minimumAge);
    }
}console
trueUsing equality operators 
java
public class Main {
    public static void main(String[] args) {
        String bookCondition = "good";
        System.out.println(bookCondition == "poor");
        System.out.println(bookCondition == "good");
    }
}console
false
trueStrict and loose equality 
In Java, equality is strict, in the sense that == will only be true if the data has the same value and the same type.
java
public class Main {
    public static void main(String[] args) {
        String userId = "123";
        int inputId = 123;
        System.out.println(userId == inputId); // error!
        System.out.println(userId == Integer.toString(inputId)); // true
    }
} Corndel
Corndel