Operators

edit

An operator is the most basic action that can be taken to evaluate values in a script. An expression is one-to-many consecutive operations. Precedence is the order in which an operator will be evaluated relative to another operator. Associativity is the direction within an expression in which a specific operator is evaluated. The following table lists all available operators:

Operator

Category

Symbol(s)

Precedence

Associativity

Precedence

General

()

0

left → right

Method Call

Reference

. ()

1

left → right

Field Access

Reference

.

1

left → right

Null Safe

Reference

?.

1

left → right

Function Call

General

()

1

left → right

Array Initialization

Array

[] {}

1

left → right

Array Access

Array

[]

1

left → right

Array Length

Array

.

1

left → right

List Initialization

Reference

[]

1

left → right

List Access

Reference

[]

1

left → right

Map Initialization

Reference

[:]

1

left → right

Map Access

Reference

[]

1

left → right

Post Increment

Numeric

++

1

left → right

Post Decrement

Numeric

 — 

1

left → right

Pre Increment

Numeric

++

2

right → left

Pre Decrement

Numeric

 — 

2

right → left

Unary Positive

Numeric

+

2

right → left

Unary Negative

Numeric

-

2

right → left

Boolean Not

Boolean

!

2

right → left

Bitwise Not

Numeric

~

2

right → left

Cast

General

()

3

right → left

New Instance

Reference

new ()

3

right → left

New Array

Array

new []

3

right → left

Multiplication

Numeric

*

4

left → right

Division

Numeric

/

4

left → right

Remainder

Numeric

%

4

left → right

String Concatenation

Reference

+

5

left → right

Addition

Numeric

+

5

left → right

Subtraction

Numeric

-

5

left → right

Left Shift

Numeric

<<

6

left → right

Right Shift

Numeric

>>

6

left → right

Unsigned Right Shift

Numeric

>>>

6

left → right

Greater Than

Boolean

>

7

left → right

Greater Than Or Equal

Boolean

>=

7

left → right

Less Than

Boolean

<

7

left → right

Less Than Or Equal

Boolean

<=

7

left → right

Instanceof

Boolean

instanceof

8

left → right

Equality Equals

Boolean

==

9

left → right

Equality Not Equals

Boolean

!=

9

left → right

Identity Equals

Boolean

===

9

left → right

Identity Not Equals

Boolean

!==

9

left → right

Bitwise And

Numeric

&

10

left → right

Boolean Xor

Boolean

^

11

left → right

Bitwise Xor

Numeric

^

11

left → right

Bitwise Or

Numeric

|

12

left → right

Boolean And

Boolean

&&

13

left → right

Boolean Or

Boolean

||

14

left → right

Conditional

General

? :

15

right → left

Elvis

General

?:

16

right → left

Assignment

General

=

17

right → left

Compound Assignment

General

$=

17

right → left