> ## 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 Bitwise OR

The `|` operator in Java functions as both a **bitwise inclusive OR** operator for integral types and a **logical non-short-circuiting OR** operator for boolean types. It evaluates two operands and yields a result based on whether at least one of the corresponding bits or boolean expressions evaluates to a positive state (`1` or `true`).

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

## Bitwise Inclusive OR (Integral Types)

When applied to integral data types (`byte`, `short`, `int`, `long`, `char`), the `|` operator performs a bit-by-bit comparison of the binary representations of the operands.

For each corresponding bit position, the operator applies the following truth table:

* `0 | 0 = 0`
* `0 | 1 = 1`
* `1 | 0 = 1`
* `1 | 1 = 1`

```java theme={"dark"}
int a = 10;      // Binary: 0000 1010
int b = 6;       // Binary: 0000 0110
int c = a | b;   // Binary: 0000 1110 (Decimal: 14)
```

**Numeric Promotion Rules:**
Before the bitwise operation occurs, Java applies binary numeric promotion:

* If either operand is of type `long`, the other operand is promoted to `long`, and the result is `long`.
* Otherwise, both operands are promoted to `int` (even if they are `byte`, `short`, or `char`), and the result is `int`.

## Logical Non-Short-Circuiting OR (Boolean Types)

When applied to `boolean` operands, the `|` operator evaluates to `true` if either the left-hand operand or the right-hand operand is `true`.

Crucially, the `|` operator guarantees the evaluation of **both** operands. This is the mechanical difference between the bitwise/logical OR (`|`) and the conditional OR (`||`). The conditional OR short-circuits (skips evaluating the right-hand operand if the left-hand operand is `true`), whereas the `|` operator forces full evaluation.

```java theme={"dark"}
boolean a = true;

// The right-hand expression is evaluated even though 'a' is already true.
// This will throw an ArithmeticException due to division by zero.
boolean result = a | (10 / 0 == 0); 
```

**Return Type:**
When both operands are `boolean`, the return type of the `|` operation is strictly `boolean`. It cannot be mixed with integral types; attempting to use `|` with one `boolean` and one numeric type results in a compilation error.

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