Operators

Purpose of this chapter.

We will learn about the operators which is the elements that make up the expression.

Operation to instances.

An operator is a symbol that specifies the operation to be performed on an instance. The operator performs an operation on the operand and returns an instance of the result.

Operators have precedence. Expressions that contain multiple operators are computed from operators with higher priorities.

The following is a list of operators. The smaller the group number is the higher the priority. Operators of the same group have the same priority. If operators with the same priority are adjacent, the operation is executed in order from the left of the expression.

First group | ||

() | x(y) | method call operator |

new | new int() | new operator |

this | this | this operator |

Second group | ||

. | x.y | dot operator |

+ | +x | unary + operator |

- | -x | unary - operator |

! | !x | logical negation operator |

Third group | ||

* | x * y | multiplication operator |

/ | x / y | division operator |

% | x % y | remainder operator |

4th group | ||

+ | x + y | addition operator |

- | x - y | subtraction operator |

5th group | ||

< | x < y | less than operator |

<= | x <= y | less than or equal operator |

> | x > y | greater than operator |

>= | x >= y | greater than equal operator |

6th group | ||

== | x == y | value equality operator |

!= | x != y | value inequality operator |

$$ | x $$ y | reference equality operator |

!$ | x !$ y | reference inequality operator |

7th group | ||

& | x & y | logical AND operator |

8th group | ||

| | x | y | logical OR operator |

Let's explain the operators of each group in the following chapter.

Copyright © Rice All rights reserved.