Category |
Operator |
Description |
Usage Example |
Value/Result |
String |
+ |
concatenation |
"Java" + "Script" |
|
Arithmetic |
+ |
addition |
3 + 3 |
|
- |
subtraction |
6 - 2 |
|
unary negation |
-4 |
|
* |
multiplication |
4 * 4 |
|
/ |
division |
15/5 |
|
% |
modulus |
22%7 |
|
++ |
increment and then return value |
x=4; ++x |
|
return value and then increment |
x=4; x++ |
|
-- |
decrement and then return value |
x=3; --x |
|
return value and then decrement |
x=4; x-- |
|
Bit Manipulation |
& |
and |
11 & 7 |
|
| |
or |
8 | 7 |
|
^ |
exclusive or |
1 ^ 7 |
|
<< |
left shift |
8 << 3 |
|
>> |
sign-propagating right shift |
-3 >> 2 |
|
>>> |
zero-fill right shift |
-7 >>> 3 |
|
Logical |
&& |
logical and |
true && false |
|
|| |
logical or |
true || false |
|
! |
not |
!true |
|
Comparison |
== |
equal |
3 == 7 |
|
!= |
not equal |
3 != 7 |
|
< |
less than |
3 < 7 |
|
<= |
less than or equal |
3 <= 7 |
|
> |
greater than |
3 > 7 |
|
>= |
greater than or equal |
3 >= 7 |
|
Conditional Expression |
(condition) ? value1 : value2 |
if condition is true then value1 else value2 |
true ? 3 : 7 |
|