Java中的算术运算符列表
欢马劈雪 最近更新时间:2020-01-02 10:19:05
| Operators | Description | Type | Usage | Result |
|---|
| + | Addition | Binary | 2 + 5 | 7 |
| - | Subtraction | Binary | 5 - 2 | 3 |
| + | Unary plus | Unary | +5 | Positive five. Same as 5 |
| - | Unary minus | Unary | -5 | Negative of five |
| * | Multiplication | Binary | 5 * 3 | 15 |
| / | Division | Binary | 5 / 2 | 2 |
| % | Modulus | Binary | 5 % 3 | 2 |
| ++ | Increment | Unary | num++ | Evaluates to the value of num, increments num by 1. |
| -- | Decrement | Unary | num-- | Evaluates to the value of num, decrements num by 1. |
| += | Arithmetic compound-assignment | Binary | num += 5 | Adds 5 to the value of num and assigns the result to num. |
| -= | Arithmetic compound assignment | Binary | num -= 3 | Subtracts 3 from the value of num and assigns the result to num. |
| *= | Arithmetic compound assignment | Binary | num *= 15 | Multiplies 15 to the value of num and assigns the result to num. |
| /= | Arithmetic compound assignment | Binary | num /= 5 | Divides the value of num by 5 and assigns the result to num. |
| %= | Arithmetic compound assignment | Binary | num %= 5 | Calculates the remainder of num divided by 5 and assigns the result to num. |