Relational Operator greater than in Java
Introduction
Relation operator Greater Than( > ) and the operator Greater than Equal to (>=) compares two variables for the relation greater than or greater than equal to.
> Relational Operator
a > b evaluates to true if a is greater than b else false
Similarly,
a >= b evaluates to true if a is greater than Equal to b else false
Code Listing
//GreaterThanOperatorDemo.java
//www.TestingDocs.com
public class GreaterThanOperatorDemo {
public static void main(String[] args) {
int a = 10;
int b = 20;
if(a > b ) {
System.out.println("a is greater than b");
}
else {
System.out.println("a is not greater than b");
}
System.out.println("The expression a > b evaluates to = " + (a > b));
}
}
Sample Output
a is not greater than b
The expression a > b evaluates to = false
Screenshot

>= Relational Operator
//GreaterThanEqualToOperatorDemo.java
//www.TestingDocs.com
public class GreaterThanEqualToOperatorDemo {
public static void main(String[] args) {
int a = 20;
int b = 20;
if(a >= b ) {
System.out.println("a is greater than or Equal to b");
}
else {
System.out.println("a is not greater than or Equal to b");
}
System.out.println("The expression a > b evaluates to = " + (a >= b));
}
}