Java does not have a built-in exponentiation operator. The ^ symbol in Java is the bitwise XOR operator, not an exponentiation operator.
public class BitwiseXORExample {
public static void main(String[] args) {
// Example 1: Using ^ for bitwise XOR
int a = 5; // Binary: 0101
int b = 3; // Binary: 0011
int result = a ^ b; // Binary: 0110 (Decimal: 6)
System.out.println("Result of bitwise XOR: " + result);
// Example 2: Using ^ for toggling a single bit
int num = 8; // Binary: 1000
int mask = 1; // Binary: 0001
int toggled = num ^ mask; // Toggle the rightmost bit
System.out.println("Toggled result: " + toggled);
}
}