Operator | Description | Example | Result |
+ (Unary) | Sign identification | +1 | 1 |
+ (Binary) | Addition | 2 + 2 | 4 |
- (Unary) | Negation | -x | The sign of x is changed. |
- (Binary) | Subtraction | 3 - 2 | 1 |
++ (Prefix) | Increment and then return the new value. | x=1;
y=++x; | The value of x is 2 and the value of y is 2 . |
++ (Postfix) | Return the current value and then increment. | x=1;
y=x++; | The value of x is 2 and the value of y is 1 . |
-- (Prefix) | Decrement and then return the new value. | x=1;
y=--x; | The value of x is 0 and the value of y is 0 . |
-- (Postfix) | Return the current value and then decrement. | x=1;
y=x--; | The value of x is 0 and the value of y is 1 . |
* | Multiplication. | 4 * 4 | 16 |
/ | Division. Note that rounding towards zero is used with integer types. | 19 / 4 | 4 |
% | Remainder. Take the remainder after division. The sign of the operand determines the sign of the result. | 19 % 4 | 3 |
+ (String) | String concatenation. | "abc" + "def" | "abcdef" |