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

The `*` operator in Java is a binary arithmetic operator that performs multiplication on two numeric operands. It calculates the product of its left and right operands, strictly adhering to Java's rules for binary numeric promotion and IEEE 754 arithmetic standards.

```java theme={"dark"}
Type result = operand1 * operand2;
```

## Operand Types

The `*` operator accepts operands of any primitive numeric type (`byte`, `short`, `char`, `int`, `long`, `float`, `double`). It also accepts their corresponding object wrapper classes (e.g., `Integer`, `Double`), which the Java compiler automatically unboxes into their primitive equivalents before evaluation. It cannot be applied to `boolean` or non-wrapper reference types.

## Binary Numeric Promotion

Before the multiplication occurs, Java applies binary numeric promotion to equalize the operand types. The promotion follows a strict hierarchy:

1. If either operand is of type `double`, the other is promoted to `double`. The result is a `double`.
2. Otherwise, if either operand is `float`, the other is promoted to `float`. The result is a `float`.
3. Otherwise, if either operand is `long`, the other is promoted to `long`. The result is a `long`.
4. Otherwise, both operands are promoted to `int` (this includes `byte`, `short`, and `char`). The result is an `int`.

```java theme={"dark"}
byte a = 10;
byte b = 5;
// result is of type int, not byte
int result = a * b; 
```

## Precedence and Associativity

The `*` operator has multiplicative precedence. It is evaluated after unary operators (like `++` or `!`) but before additive operators (`+` and `-`).

It features **left-to-right associativity**, meaning an expression with multiple multiplicative operators (`*`, `/`, `%`) is evaluated from left to right.

```java theme={"dark"}
// Evaluated as (a * b) * c
int result = a * b * c; 
```

## Overflow Behavior

Java handles multiplication overflow differently depending on whether the operands are integers or floating-point numbers:

* **Integer Arithmetic (`int`, `long`):** If the mathematical product exceeds the maximum or minimum bounds of the resulting type, the operation silently wraps around using two's complement arithmetic. It does **not** throw an `ArithmeticException`.
* **Floating-Point Arithmetic (`float`, `double`):** If the product exceeds the maximum representable finite value, the result overflows to positive or negative `Infinity`, depending on the signs of the operands.

## IEEE 754 Special Cases

When multiplying floating-point numbers, the `*` operator follows IEEE 754 specifications for special values:

* **NaN (Not a Number):** If either operand is `NaN`, the result is `NaN`.
* **Infinity by Zero:** Multiplying positive or negative `Infinity` by `0` or `0.0` results in `NaN`.
* **Infinity by Finite:** Multiplying `Infinity` by any non-zero finite value results in `Infinity`. The sign of the resulting `Infinity` is positive if both operands have the same sign, and negative if they have different signs.
* **Signed Zeros:** Java supports `-0.0` and `+0.0`. Multiplying two zeros yields a zero, with the sign determined by the standard XOR sign rules (e.g., `-0.0 * +0.0` yields `-0.0`).

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