---
title: "Which are the Expression Operators, Apex supports in Salesforce?"  
description: "Which are the Expression Operators, Apex supports in Salesforce?"  
author: "Simone Palmer"  
published: 2018-01-24  
canonical: https://answers.mindstick.com/qa/33585/which-are-the-expression-operators-apex-supports-in-salesforce  
category: "salesforce"  
tags: ["salesforce", "expression operators", "operators", "apex"]  
reading_time: 9 minutes  

---

# Which are the Expression Operators, Apex supports in Salesforce?

Which are the [Expression](https://www.mindstick.com/articles/1861/sqlite-expressions) [Operators](https://www.mindstick.com/articles/716/php-operators), [Apex](https://www.mindstick.com/blog/12039/tips-to-learn-salesforce-apex-quickly-from-the-scratch) [supports](https://www.mindstick.com/blog/12043/how-to-create-a-killer-mobile-app-that-supports-your-brand) in [Salesforce](https://yourviews.mindstick.com/view/82645/what-you-need-to-know-to-get-started-on-salesforce-field-service)?

## Answers

### Answer by Tarun Gautam

In SalesForce Visualforce uses Operators to join expressions together to create compound expressions, and Operators must be used within Visualforce expression syntax to be evaluated.

**Apex supported operator are as follows**:

| **Operator Name** | **Operator** | **Syntax** | **Description** |
| --- | --- | --- | --- |
| Assignment operator | = | x = y | This operator Assigns the value of y to the L-value x. Note that the data type of x must match the data type of y, and cannot be null. |
| Addition assignment operator | += | x += y | This operator Adds the value of y to the original value of x and then reassigns the new value to x. See + for additional information. x and y cannot be null. |
| Division assignment operator | /= | x /= y | This operator Divides the original value of x with the value of y and then reassigns the new value to x. Note that x and y must be Integers or Doubles, or a combination. x and y cannot be null. |
| Subtraction assignment operator | -= | x -= y | This operator Subtracts the value of y from the original value of x and then reassigns the new value to x. Note that x and y must be Integers or Doubles, or a combination. x and y cannot be null |
| Multiplication assignment operator | *= | x *= y | This operator Multiplies the value of y with the original value of x and then reassigns the new value to x. Note that x and y must be Integers or Doubles, or a combination. x and y cannot be null. |
| Multiplication assignment operator | *= | x *= y | This operator Multiplies the value of y with the original value of x and then reassigns the new value to x. Note that x and y must be Integers or Doubles, or a combination. x and y cannot be null. |
| assignment operator | \|= | x \|= y | If var x is a Boolean, and var y is a Boolean, and both false, then var x remains false. Otherwise, var x is assigned the value of true. x and y cannot be null. |
| AND assignment operator | &= | x &= y | If var x, a Boolean, and y, a Boolean, are both true, then x remains true. Otherwise, x is assigned the value of false. x and y cannot be null. |
| Bitwise shift left assignment operator | <<= | x <<= y | Shifts each bit in x to the left by y bits so that the high order bits are lost, and the new right bits are set to 0. This value is then reassigned to x. |
| Bitwise shift right signed assignment operator | >>= | x >>= y | Shifts each bit in x to the right by y bits so that the low order bits are lost, and the new left bits are set to 0 for positive values of y and 1 for negative values of y. This value is then reassigned to x. |
| Bitwise shift right unsigned assignment operator | >>>= | x >>>= y | Shifts each bit in x to the right by y bits so that the low order bits are lost, and the new left bits are set to 0 for all values of y. This value is then reassigned to x. |
| Ternary operator | ? : | x ? y : z | This operator acts as a short-hand for if-then-else statements. If x, a Boolean, is true, y is the result. Otherwise, z is the result. Note that x cannot be null. |
| AND logical operator | && | x && y | If var x, a Boolean, and var y, a Boolean, are both true, then the expression evaluates to true. Otherwise, the expression evaluates to false. Note: && has precedence over \|\| This operator exhibits “short-circuiting” behavior, which means y is evaluated only if x is true. x and y cannot be null. |
| OR logical operator | \|\| | x \|\| y | If var x, a Boolean, and var y, a Boolean, are both false, then the expression evaluates to false. Otherwise, the expression evaluates to true. Note: && has precedence over \|\| This operator exhibits "short-circuiting" behavior, which means y is evaluated only if x is false. x and y cannot be null. |
| Equality operator | == | x == y | If the value of var x equals the value of var y, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Exact equality operator | === | x === y | If var x and var y reference the exact same location in memory, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Less than operator | < | x < y | If var x is less than var y, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Greater than operator | > | x > y | If var x is greater than var y, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Less than or equal to operator | <= | x <= y | If var x is less than or equal to var y, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Greater than or equal to operator | >= | x >= y | If var x is greater than or equal to var y, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Inequality operator | != | x != y | If the value of var x does not equal the value of var y, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Exact inequality operator | !== | x !== y | If var x and var y do not reference the exact same location in memory, the expression evaluates to true. Otherwise, the expression evaluates to false. |
| Addition operator | + | x + y | This will Adds the value of x to the value of y. |
| Subtraction operator | - | x - y | This will Subtracts the value of y from the value of x. |
| Multiplication operator | * | x * y | This will Multiplies x, an Integer or Double, with y, another Integer or Double. Note that if a double is used, the result is a Double. |
| Division operator | / | x / y | This will Divides x, an Integer or Double, by y, another Integer or Double. Note that if a double is used, the result is a Double. |
| Logical complement operator | ! | !x | This will Inverts the value of a Boolean, so that true becomes false, and false becomes true. |
| Unary negation operator | - | -x | This will Multiplies the value of x, an Integer or Double, by -1. Note that the positive equivalent + is also syntactically valid, but does not have a mathematical effect. |
| Increment operator | ++ | x++ \ ++x \ \ | This will Adds 1 to the value of x, a variable of a numeric type. If prefixed (++x), the expression evaluates to the value of x after the increment. If postfixed (x++), the expression evaluates to the value of x before the increment. |
| Decrement operator | -- | x-- \ --x \ \ | This will Subtracts 1 from the value of x, a variable of a numeric type. If prefixed (--x), the expression evaluates to the value of x after the decrement. If postfixed (x--), the expression evaluates to the value of x before the decrement. |
| Bitwise AND operator | & | x & y | ANDs each bit in x with the corresponding bit in y so that the result bit is set to 1 if both of the bits are set to 1. This operator is not valid for types Long or Integer. |
| Bitwise OR operator | \| | x \| y | ORs each bit in x with the corresponding bit in y so that the result bit is set to 1 if at least one of the bits is set to 1. This operator is not valid for types Long or Integer. |
| Bitwise exclusive OR operator | ^ | x ^ y | Exclusive ORs each bit in x with the corresponding bit in y so that the result bit is set to 1 if exactly one of the bits is set to 1 and the other bit is set to 0. |
| Bitwise exclusive OR operator | ^= | x ^= y | Exclusive ORs each bit in x with the corresponding bit in y so that the result bit is set to 1 if exactly one of the bits is set to 1 and the other bit is set to 0. Assigns the result of the exclusive OR operation to x. |
| Bitwise shift left operator | << | x << y | This will Shifts each bit in x to the left by y bits so that the high order bits are lost, and the new right bits are set to 0. |
| Bitwise shift right signed operator | >> | x >> y | This will Shifts each bit in x to the right by y bits so that the low order bits are lost, and the new left bits are set to 0 for positive values of y and 1 for negative values of y. |
| Bitwise shift right unsigned operator | >>> | x >>> y | This will Shifts each bit in x to the right by y bits so that the low order bits are lost, and the new left bits are set to 0 for all values of y. |
| Parentheses | () | (x) | This will Elevates the precedence of an expression x so that it is evaluated first in a compound expression. |


---

Original Source: https://answers.mindstick.com/qa/33585/which-are-the-expression-operators-apex-supports-in-salesforce

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
