You are here: Home / Topics / Program to use Bitwise Short-hand assignment operator in Java

Program to use Bitwise Short-hand assignment operator in Java

Filed under: Java on 2023-08-11 19:31:45

// Program to use Bitwise Short-hand assignment operator

class BitwiseShortHandAssignmentOperator
{
public static void main( String args[ ] )
{
 int a = 13;
 System.out.println("a : " + a);
 
 a &= 4;
 System.out.println("a &= 4 : " + a);
 
 a |= 3;
 System.out.println("a |= 3 : " + a);
 
 a ^= 8;
 System.out.println("a ^= 8 : " + a);
 
 a <<= 3;
 System.out.println("a <<= 3 : " + a);
 
 a >>= 2;
 System.out.println("a >>= 2 : " + a);
 
 a >>>= 3;
 System.out.println("a >>>= 3 : " + a);
}
}


Output:

a : 14
a &= 4 : 4
a |= 3 : 7
a ^= 8 : 15
a <<= 3 : 120
a >>= 2 : 30
a >>>= 3 : 3

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.