OPERATORS (ARITHMETIC, RELATIONAL, BOOLEAN LOGICAL, BITWISE LOGICAL, ASSIGNMENT, UNARY, SHIFT, SPECIAL OPERATORS) in JAVA

 


Java Operators

Operator Type Operator Description Example
Arithmetic + Addition a + b
- Subtraction a - b
* Multiplication a * b
/ Division a / b
% Modulus (remainder) a % b
Relational == Equal to a == b
!= Not equal to a != b
< Less than a < b
> Greater than a > b
<= Less than or equal to a <= b
>= Greater than or equal to a >= b
Boolean Logical && Logical AND (a > b) && (b > c)
|| Logical OR (a > b) || (b > c)
! Logical NOT !(a > b)
Bitwise Logical & Bitwise AND a & b
| Bitwise OR a | b
^ Bitwise XOR a ^ b
~ Bitwise Complement ~a
Assignment = Assign value a = b
+= Add and assign a += b
-= Subtract and assign a -= b
*= Multiply and assign a *= b
/= Divide and assign a /= b
%= Modulus and assign a %= b
Unary + Unary plus +a
- Unary minus -a
++ Increment ++a, a++
-- Decrement --a, a--
! Logical NOT !a
Shift << Left shift a << 2
>> Right shift (sign-preserving) a >> 2
>>> Unsigned right shift a >>> 2
Special Operators ?: Ternary operator a > b ? x : y
instanceof Tests if an object is an instance of a class/interface obj instanceof String

Post a Comment

Thanks for comment.

Previous Post Next Post