If p
is 10 and q
is 10, the result of the expression p == q
using the equality operator (==
) in Java would be true
. The equality operator checks if the values on both sides are equal, and in this case, both p
and q
have the value of 10.
Here's a simple example:
public class EqualityOperatorExample {
public static void main(String[] args) {
// Example values
int p = 10;
int q = 10;
// Check if p is equal to q
boolean result = p == q;
// Print the result
System.out.println("Is p equal to q? " + result);
}
}
In this case, the output will be:
Is p equal to q? true