---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 13 Edition"
java_version: 13
chapter: "Chapter 15. Expressions"
section: "15.24"
heading: "15.24. Conditional-Or Operator ||"
parent: "Chapter 15. Expressions"
source: https://docs.oracle.com/javase/specs/jls/se13/html/jls-15.html#jls-15.24
id: "15.24"
url: https://jvm.obfuscated.software/jls/se13/15.24.html
raw: https://jvm.obfuscated.software/jls/se13/15.24.md
---

# 15.24. Conditional-Or Operator `||`

The conditional-or operator `||` operator is like `|` ([§15.22.2](15.22.2.md)), but evaluates its right-hand operand only if the value of its left-hand operand is `false`.

```
ConditionalOrExpression:
  ConditionalAndExpression
  ConditionalOrExpression || ConditionalAndExpression
```

The conditional-or operator is syntactically left-associative (it groups left-to-right).

The conditional-or operator is fully associative with respect to both side effects and result value. That is, for any expressions `a`, `b`, and `c`, evaluation of the expression `((a) || (b)) || (c)` produces the same result, with the same side effects occurring in the same order, as evaluation of the expression `(a) || ((b) || (c))`.

Each operand of the conditional-or operator must be of type `boolean` or `Boolean`, or a compile-time error occurs.

The type of a conditional-or expression is always `boolean`.

At run time, the left-hand operand expression is evaluated first; if the result has type `Boolean`, it is subjected to unboxing conversion ([§5.1.8](5.1.8.md)).

If the resulting value is `true`, the value of the conditional-or expression is `true` and the right-hand operand expression is not evaluated.

If the value of the left-hand operand is `false`, then the right-hand expression is evaluated; if the result has type `Boolean`, it is subjected to unboxing conversion ([§5.1.8](5.1.8.md)). The resulting value becomes the value of the conditional-or expression.

Thus, `||` computes the same result as `|` on `boolean` or `Boolean` operands. It differs only in that the right-hand operand expression is evaluated conditionally rather than always.
