From our previous video of our ongoing Core Java course we have learnt that what are Relational operators in Java. In this video we are going to learn about Bitwise Operators in Java.
Bitwise Operators in Java can be applied to the integer types long, short, int, char, and byte. They perform operations on individual bits, and the result is also always a bit.
Bitwise operators in Java works on bit and performs bit by bit operation.
Assume if a=60; and b=13;
Binary is :
Now we will do Programming for Bitwise operators in Java.
public static void main(String args)
System.out.println("Before left shift: " + x);
System.out.println("After left shift: " + ans);
System.out.println("Before right shift: " + y);
System.out.println("After right shift: " + ans);
Before left shift: 10
After left shift: 40
Before right shift: 40
After right shift: 10
This is how Bitwise Operators in Java works. In our next video we will see that what are Logical operators in Java and what is the use of Logical operators in Java.
Have a friend to whom you would want to share this course?