In this section, you will learn how to use Left Shift "<<"
operator in Java. The Java programming language has operators that perform bitwise operations. In the example below we have shown the usage of
Left Shift "<<"
operator.
Description of code:
The Left Shift "<<"
operator shifts the left operand to the left side by the number of bits specified by its right operand.
This operator never throws an exception. Each operand of the left shift operator must be an integer data
type otherwise a compile-time error will occur. The following example shows
displays the code of left shift operator.
Here is the code of program:
|
Output of the program:
| C:\unique>javac leftshift.java C:\unique>java leftshift << opeartor -9 << 3 = -72 9 << 3 = 72 C:\unique> |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Java Left Shift "<<" Operator View All Comments
Post your Comment