Professional Documents
Culture Documents
Unary Operators: Symbo L Name of The Operator Operation Example
Unary Operators: Symbo L Name of The Operator Operation Example
The unary operators requires only one operand to perform different kind of
operations such as increasing/decreasing a value, negating an expression,
or inverting a boolean value.
The unary operators requires only one operand to perform different kind
of operations such as increasing/decreasing a value, negating an
expression, or inverting a boolean value. These operators can not be
used with final variables. There are different types of unary operators
mentioned in the table given below:
Symbo Name of the
Operation Example
l Operator
Unary plus indicates positive value (however, int number
+
operator numbers are positive without this) = +1;
Unary minus number = -
- negates an expression
operator number;
Increment number = ++
++ increments a value by 1
operator number;
Decrement number = --
-- decrements a value by 1
operator number;
Logical
! compliment inverts a boolean value
operator
Binary operator
Operator Name
, Comma
!= Inequality
% Modulus
%= Modulus/assignment
* Multiplication
*= Multiplication/assignment
+ Addition
+= Addition/assignment
– Subtraction
–= Subtraction/assignment
/ Division
/= Division/assignment
= Assignment
== Equality
> Greater than
^ Exclusive OR
^= Exclusive OR/assignment
| Bitwise inclusive OR
|| Logical OR