Bit Operations in Java

0

 

In this blog we learn about how can we perform the bit operations in java. Operations like and, or, not, left shift and right shift.


class HindiCodingCommunity
{
public static void main(String args[])
{
int first=5;
int second=8;
//And of first and second
System.out.println(first & second);

// or of first and second
System.out.println(first | second);

// not of the first
System.out.println(~first);

//left shift by 2
System.out.println(first<<2);

//right shift by 2
System.out.println(second>>2);


}
}

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !