Bit-wise Operator Java Program
Operator is very important for all languages. Operator can calculate, check, assign, increase and decrease the value of variable. So operator is heart of java program. I give simple example of operator java program.
“X & Y”;
In this example X and Y are variable;
& (Bitwise) is an operator”
So we can easily understand the import of operator in java program language. In this blog we will discuss on Bitwise [ &, | , ^, >> , << , >>> ] operators.
&, | , ^, >> , << , >>>are bit-wise operator in java programming languages. These operators help for check binary numbers. We are familiar with this operator in C and Cpp. They are working same as C and Cpp.
Let’s see simple structure of bit-wise operator.
&, | and ^ Binary Chart
|No||Statement||And [ & ]||Or [ | ]||XOR [ ^ ]|
|1||1 , 1||1||1||0|
Let’s see simple example on this operator.
int X = 137;
int Y = 189;
You can also bit-wise operator on YouTube.
>>, <<, >>> Operator in Java Program
This all are shifting operator, which are very useful in any binary calculation program.
Let’s see simple details of this operator.
Int X = 30;
Convert into Binary
|X>>2 | Shift 2 Step Right all binary digit|
|Now New Number of X = 7|
|X<<2 | Shift 2 Step Left all binary digit|
|Now New Number of X = 120|
1182total visits,5visits today