Operators in JAVA
Operators in JAVA
Unary Operators
operator Name Description
++ Post increment Increments the value after u
Pre increment Increments the value before
-- Post increment decrements the value after u
Pre increment decrements the value before
~ Bitwise complement Flips bits of the value
! Logical negation Inverts the value of a Boole
Arithmetic Operators
Operator Description
- Subtractive operator
* Multiplication operator
/ Division operator
% Modulus operator
Relational operators:
Operator Description
== Equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
!= Not equal to
Logical Operators
Operator Name Description
&& AND The result will be true only if both expres
|| OR The result will be true if any one of the ex
The result will be false if the expression is
! NOT
a
Ternary Operator
The ternary operator is used as a single-line
replacement for if-then-else statements and acts upon
three operands.
Syntax:
Assignment Operators
Oper
Description
ator
= Assigns the value on the right to the variable on the left
Adds the current value of the variable on the left to the value on
+=
signs the result to the variable on the left
Subtracts the value of the variable on the right from the current v
-=
on left and then assigns the result to the variable on the left
Bitwise Operators: