Operation
Operator
Description
Equal To
==
Compares the values of two
variables for equality
Not Equal To
!=
Compares the values of two
variables for inequality
Greater Than
>
Checks if one value is greater
than the other value
Lesser Than
<
Checks
if one value is lesser
than the other value
Greater Than Or
Equal To
>=
Checks if one value is greater
than
or equal to the other value
Lesser
Than
Or
Equal To
<=
Checks if one value is lesser
than or equal to the other value
The Bitwise Operators
The bitwise operators available in Java can be easily applied to a number of data types.
These
data types include byte, short, long, int and char. Typically, any bitwise operator
performs the concerned operation bit-wise. For instance, if you consider the example of an
integer x, which has the value 60. Therefore, the binary equivalent of x is 00111100.
Consider
another variable y, with the value 13 or 00001101. If we perform the bitwise
operation & on these two numbers, then you will get the following result:
x&y = 0000 1100
The table shown below shows a list of bitwise operators that are available in Java.
Operation
Operator
Description
BINARY AND
&
Performs the AND operation
BINARY OR
|
Performs
the OR operation
BINARY XOR
^
Performs the XOR operation
ONE’S
COMPLEMENT
~
Performs the complementation
operation on a unary variable
BINARY
LEFT
SHIFT
<<
Performs
the left shifting of bits
BINARY
RIGHT
SHIFT
>>
Performs the right shifting of
bits
In addition to the above mentioned, Java also supports right shift zero fill operator (>>>),
which fills the shifted bits on the right with zero.
Do'stlaringiz bilan baham: