Use of shift operator in Java

Explain the use of shift operator in Java. Can you give some examples?

Using shift operators in Java we can

1. Integer division and multiplication is done faster.
Example
84547 * 4 can be done by using 84547 << 2
or
84547 / 2 can be done by using 84547 >> 1
2. To reassemble byte streams into int values
3. To accelerate operations with graphics as Red, Green and Blue colors coded by separate bytes.
Need of wrappers like Integer, Boolean for int, boolean - Java
Wrapper classes are used to represent primitive data types as objects. Dealing primitive types as objects is sometimes easier....
Array vs ArrayList vs LinkedList vs Vector in java
Array vs ArrayList: ArrayList is much better than Array, when the size need to be increased dynamically. Efficiency is possible with arrays. ArrayList permits null elements...
Define Autoboxing with an example
The automatic conversion of primitive int type into a wrapper class object is called autoboxing. It does not require to type cast the int value. The modification of primitive wrapper objects is done directly...
Post your comment