The greater-than operator (>) in Java is used to check if the left operand is greater than the right operand. In this case, 10 > 15 is false because 10 is not greater than 15.
If p
is 10 and q
is 15, the expression p > q
in Java evaluates to false
. This is because 10
is not greater than 15
.
Here's a simple Java program to illustrate this:
public class GreaterThanOperatorExample {
public static void main(String[] args) {
// Example values
int p = 10;
int q = 15;
// Check if p is greater than q
if (p > q) {
System.out.println("p is greater than q.");
} else {
System.out.println("p is not greater than q.");
}
}
}
When you run this program, it will print "p is not greater than q."