TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
> (greater than) operator is a binary relational operator that compares two numeric operands. It evaluates to a boolean value, returning true if the left-hand operand is strictly greater in mathematical value than the right-hand operand, and false otherwise.
Operand Compatibility
The> operator is strictly limited to numeric types. It cannot be applied to boolean primitives, String objects, or standard object references.
- Primitive Numerics: Compatible with
byte,short,char,int,long,float, anddouble. When applied tochar, Java evaluates the underlying 16-bit unsigned integer (UTF-16 code point) of the character. - Wrapper Classes: Compatible with numeric wrapper classes (e.g.,
Integer,Double,Character). The Java compiler applies auto-unboxing to extract the underlying primitive values before performing the comparison. If the wrapper object reference isnull, attempting to evaluate it with the>operator will throw aNullPointerExceptionat runtime during the unboxing process.
Type Promotion
If the two operands are of different numeric types, or if they are sub-integer types, Java applies binary numeric promotion according to the Java Language Specification before evaluating the expression:- If either operand is of type
double, the other is promoted todouble. - Otherwise, if either operand is
float, the other is promoted tofloat. - Otherwise, if either operand is
long, the other is promoted tolong. - Otherwise, both operands are automatically promoted to
int.
byte and a short, both are promoted to int prior to comparison; the byte is not simply widened to match the short.
Floating-Point Mechanics (IEEE 754)
When evaluating floating-point numbers (float and double), the > operator adheres to IEEE 754 standards, which introduces specific behavioral rules:
- NaN (Not a Number): If either or both operands are
NaN(e.g.,Double.NaN), the>operator strictly evaluates tofalse. - Infinity:
POSITIVE_INFINITYis considered greater than any finite number andNEGATIVE_INFINITY. - Signed Zeros: Positive zero (
0.0) and negative zero (-0.0) are considered mathematically equal. Therefore,0.0 > -0.0evaluates tofalse.
Syntax Visualization
Master Java with Deep Grasping Methodology!Learn More





