The unary operator works on a single operand. Following are the examples of unary operators supported in java. Assume A = 60 and B = 20.
|~ (bitwise compliment)||Binary One's Complement Operator is unary and has the effect of 'flipping' bits.||(~A ) will give -61 which is 1100 0011 in 2's complement form due to a signed binary number.|
|++ (Increment)||Increases the value of operand by 1.||B++ gives 21|
|-- (Decrement)||Decreases the value of operand by 1.||B-- gives 19|