> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java Greater Than

The `>` (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.

```java theme={"dark"}
operand1 > operand2
```

## 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`, and `double`. When applied to `char`, 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 is `null`, attempting to evaluate it with the `>` operator will throw a `NullPointerException` at 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:

1. If either operand is of type `double`, the other is promoted to `double`.
2. Otherwise, if either operand is `float`, the other is promoted to `float`.
3. Otherwise, if either operand is `long`, the other is promoted to `long`.
4. Otherwise, **both** operands are automatically promoted to `int`.

This means if you compare a `byte` and a `short`, both are promoted to `int` prior to comparison; the `byte` is not simply widened to match the `short`.

```java theme={"dark"}
int a = 5;
double b = 4.5;
boolean result1 = a > b; // 'a' is promoted to 5.0 before comparison. Evaluates to true.

byte c = 10;
short d = 5;
boolean result2 = c > d; // Both 'c' and 'd' are promoted to int before comparison.
```

## 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 to `false`.
* **Infinity:** `POSITIVE_INFINITY` is considered greater than any finite number and `NEGATIVE_INFINITY`.
* **Signed Zeros:** Positive zero (`0.0`) and negative zero (`-0.0`) are considered mathematically equal. Therefore, `0.0 > -0.0` evaluates to `false`.

## Syntax Visualization

```java theme={"dark"}
// Standard primitive comparison
boolean check1 = 10 > 5;           // true

// Character comparison (evaluates ASCII/UTF-16 integer values: 98 > 97)
boolean check2 = 'b' > 'a';        // true

// Auto-unboxing evaluation
Integer objVal = 50;
boolean check3 = objVal > 25;      // true (objVal is unboxed to int 50)

// NullPointerException during auto-unboxing
Integer nullVal = null;
// boolean check4 = nullVal > 0;   // Throws NullPointerException at runtime

// Floating-point edge cases
boolean check5 = 5.0 > Double.NaN; // false
boolean check6 = 0.0 > -0.0;       // false
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Java Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
