– Uniary ++, –, +, -, |, ~, ()
– Arithmetic *, /, %,+, –
-Shift <<, >>, >>>
– Comparison =, instanceof, = =,!=Bitwise &, ^, |Short Circuit &&, ||
Ternary ?:Assignment =
In Java, operators are special symbols or keywords that perform operations on operands. There are several types of operators in Java, broadly categorized as follows:
- Arithmetic Operators:
- Addition:
+
- Subtraction:
-
- Multiplication:
*
- Division:
/
- Modulus:
%
- Increment:
++
- Decrement:
--
- Addition:
- Relational Operators:
- Equal to:
==
- Not equal to:
!=
- Greater than:
>
- Less than:
<
- Greater than or equal to:
>=
- Less than or equal to:
<=
- Equal to:
- Logical Operators:
- Logical AND:
&&
- Logical OR:
||
- Logical NOT:
!
- Logical AND:
- Bitwise Operators:
- Bitwise AND:
&
- Bitwise OR:
|
- Bitwise XOR:
^
- Bitwise NOT:
~
- Left shift:
<<
- Right shift:
>>
- Unsigned right shift:
>>>
- Bitwise AND:
- Assignment Operators:
- Assign:
=
- Add and assign:
+=
- Subtract and assign:
-=
- Multiply and assign:
*=
- Divide and assign:
/=
- Modulus and assign:
%=
- Assign:
- Conditional (Ternary) Operator:
? :
- Instanceof Operator:
instanceof
- Type Cast Operator:
(type) expression
- Miscellaneous Operators:
- Conditional (Ternary) Operator:
? :
- Member access operator (
.
) - Array index access operator (
[]
) - Method call operator (
()
)
- Conditional (Ternary) Operator:
Understanding and using these operators is fundamental to writing Java programs. Each operator serves a specific purpose and operates on one or more operands to produce a result.