> ## 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 Less Than

The `<` (less than) operator is a binary relational operator that compares the values of two numeric operands. It evaluates to the `boolean` value `true` if the left-hand operand is strictly lesser in mathematical value than the right-hand operand, and `false` otherwise.

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

## Operand Compatibility

The `<` operator strictly requires operands that can be resolved to numeric types.

* **Supported Primitives:** `byte`, `short`, `char`, `int`, `long`, `float`, and `double`.
* **Unsupported Types:** `boolean`, `String`, and all object references (with the exception of numeric wrapper classes).

## Binary Numeric Promotion

Before performing the comparison, Java applies binary numeric promotion to the operands according to the Java Language Specification. This promotion occurs for all numeric comparisons based on the following strict hierarchy:

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

This means that operands of types smaller than `int` (`byte`, `short`, and `char`) are always widened to `int` prior to comparison, even if both operands are of the exact same type or if the broadest type between the two is smaller than `int`.

```java theme={"dark"}
byte a = 10;
short b = 20;
boolean result1 = a < b; // Both 'a' and 'b' are promoted to int before comparison

int c = 5;
double d = 5.5;
boolean result2 = c < d; // 'c' is promoted to double (5.0) before comparison
```

## Auto-Unboxing

If either operand is a numeric wrapper class (e.g., `Integer`, `Double`, `Character`), Java automatically unboxes the object into its corresponding primitive type before applying binary numeric promotion and evaluating the relational expression.

```java theme={"dark"}
Integer x = Integer.valueOf(10);
int y = 20;
boolean result = x < y; // 'x' is unboxed to int 10 before comparison
```

*Note: If the wrapper reference is `null`, the unboxing attempt will throw a `NullPointerException`.*

## Floating-Point Specifics

When evaluating `float` or `double` operands, the `<` operator adheres to IEEE 754 standards for floating-point arithmetic:

* **NaN (Not a Number):** If either operand is `NaN`, the `<` operator always evaluates to `false`.
* **Infinity:** Negative infinity (`-Infinity`) is considered strictly less than any finite value and positive infinity (`+Infinity`).
* **Signed Zeros:** Positive zero (`0.0`) and negative zero (`-0.0`) are considered equal. Therefore, `-0.0 < 0.0` evaluates to `false`.

```java theme={"dark"}
boolean nanCheck = Double.NaN < 5.0;             // Evaluates to false
boolean infCheck = Double.NEGATIVE_INFINITY < 0; // Evaluates to true
boolean zeroCheck = -0.0 < 0.0;                  // Evaluates to false
```

## Character Comparison

When applied to `char` operands, the `<` operator compares their 16-bit Unicode (UTF-16) integer values.

```java theme={"dark"}
char c1 = 'A'; // Unicode value 65
char c2 = 'B'; // Unicode value 66
boolean result = c1 < c2; // Evaluates to true because 65 < 66
```

<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>
