---
schema_version: "1"
id: 6c27334f5e6d98e08d60dc66e80bc0d6f7dbe4558342ceb75470789a95d89db3
title: Operator Precedence
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/langCon_apex_expressions_operators_precedence.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_expressions_operators_precedence.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b39744760e20980313d63e40b0fab1e1b55d156e56dd4c3d47ef2ca32516b003
description: Operators are interpreted in order, according to rules.
---
# Operator Precedence

Operators are interpreted in order, according to rules.

Apex uses the following operator precedence rules:

| Precedence | Operators | Description |
| --- | --- | --- |
| 1 | {} () ++ -- | Grouping and prefix increments and decrements |
| 2 | ~ ! -x +x (type) new | Unary operators, additive operators, type cast and object creation |
| 3 | \* / | Multiplication and division |
| 4 | \+ - | Addition and subtraction |
| 5 | << >> >>> | Shift Operators |
| 6 | < <= > >= instanceof | Greater-than and less-than comparisons, reference tests |
| 7 | \== != | Comparisons: equal and not-equal |
| 8 | & | Bitwise AND |
| 9 | ^ | Bitwise XOR |
| 10 | | | Bitwise OR |
| 11 | && | Logical AND |
| 12 | || | Logical OR |
| 13 | ?? | Null Coalescing |
| 14 | ?: | Ternary |
| 15 | \= += -= \*= /= &= <<= >>= >>>= | Assignment operators |