Operators
List of Operators
Here is the list of all the operators you can use in expressions:
Operator | Name | Operands | Description |
---|---|---|---|
() | Parenthesis | An expression | Affects the evaluation order of expressions. |
+ | Addition or concatenation | Two numeric arguments for addition or two string arguments for concatenation | Adds two numeric expressions or concatenates two string expressions |
- | Subtraction or negation | One or two numeric arguments | Unary negation operator negates the argument. Binary subtraction operator subtracts the second argument from the first one. |
* | Multiplication | Two numeric arguments. | Multiplies two numeric expressions. |
/ | Division | Two numeric arguments. | Divides the first numeric expression by the second one. |
% | Modulo | Two integer arguments | Returns the remainder after division of the first expression by the second one. |
&& | Logical AND | Two boolean arguments | Returns true if both arguments are true. Otherwise, returns false. |
|| | Logical OR | Two boolean arguments | Returns true if at least one argument is true. Otherwise, returns false. |
! | Logical negation | One boolean arguments | Returns true if the argument is false. Otherwise, returns false. |
== | Equality | Two expressions | Checks whether the expressions are equal |
!= | Inequality | Two expressions | Checks whether the expressions are not equal |
< | Less than | Two numeric expressions | Checks whether the first arguments is less than the second one. |
> | Greater than | Two numeric expressions | Checks whether the first arguments is greater than the second one. |
<= | Less than or equal to | Two numeric expressions | Checks whether the first arguments is less than or equal to the second one. |
>= | Greater than or equal to | Two numeric expressions | Checks whether the first arguments is greater than or equal to the second one. |
? : | Conditional operator | Boolean expression and two expressions of any type | If the boolean condition argument (before the question mark) is true, returns the second argument (after the quesstion mark); otherwise, returns the third argument (after colon). If the condition is null, the operator returns null. |
Order of Evaluation
Operators are evaluated in the following order:
- Parenthesis
- Unary minus, logical negation
- *, /
- +, -
- <, >, <=, >=
- ==, !=
- &&
- ||
- ? :