Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Java

Greater-than operator (>)

The > operator checks whether the left operand is strictly greater than the right and returns boolean. Equal values produce false. It operates on numeric values after numeric promotion; a comparison involving NaN always produces false.

Version: Java SE 21; repository runtime, production runtime not attested

Syntax

left > right

left > right returns true only when the left value is strictly greater than the right. Its result has type boolean. Unlike >=, > excludes equality.

Operands must be numeric or support unboxing to primitive numeric types. Java applies binary numeric promotion to a common type. Unboxing a null wrapper throws NullPointerException; mixing integer and floating-point types can lose precision during conversion.

If either operand is NaN, the result is false. Positive and negative zero compare as equal. Writing a > b > c is a compile-time error; use a > b && b > c.

Examples

public class Main {
    public static void main(String[] args) {
        int score = 80;
        int threshold = 75;
        System.out.println(score > threshold);
        System.out.println(score > 80);
        System.out.println(Double.NaN > threshold);
    }
}

Result

true
false
false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources