Java Reference
In-Depth Information
Operators
There are four main types of operator.
•
Arithmetic operators
•
The Bitwise operators
•
Relational operators
•
Boolean logical operators
Arithmetic operators
•
Addition-
This operator is used to add the values. It is represented by “+“.
For
example
A = a + 4.
•
Subtraction-
This operator is used to subtract the values. It is represented by
“- “.
For example
A = a - 4.
•
Multiplication-
This operator is used to multiply the values. It is represented
by “*“.
For example
A = a * 4.
•
Division-
This operator is used to divide the values. It is represented by “/“.
For example
A = a / 4.
•
Modulus-
This operator is used to find the remainder of the values when di-
vided. It is represented by “%“.
For example
A = 2 % 4. Where A = 0.
•
Increment-
This operator is used to increases its operand by one. It is repres-
ented by “++“.
For example
a = a++ which is equal to a= a+1.
•
Decrement:
This operator is used to decreases its operands by one. It is rep-
resented by “--“.
For example
a = a-- which is equal to a= a-1.
Bitwise operators
Unary NOT-
This inverts all of the bits of operand contained and it is represented by “~“.
For example
~00101010 = 11010101
And-
It produces 1 bit if both operands are also 1 and it is represented by “&“.
For example
00101010