+ 6
Symbol (^) in Java
What does this symbol ^ refer to ?
4 Respostas
+ 5
^ - bitwise operator XOR
You can swap the bits of a number with it, to get a new number.
Substraction and Addition:
1111 (15) ^ 0101 (5) = 1010 (10)
1010 (10) ^ 0101 (5) = 1111 (15)
1100 (12) ^ 0100 (4) = 1000 (8)
1000 (8) ^ 0100 (4) = 1100 (12)
+ 4
Prints counter i reversed:
for (int i = 0; i < 16; i++) {
System.out.println(i ^ 15);
}
+ 3
Search for bitwise operators in Java.
(^ refers to bitwise XOR)
An example :
https://www.tutorialspoint.com/java/java_bitwise_operators_examples.htm
+ 3
^ does not mean "power to" (that's what Math.pow(x,y) is for). ^ is the bitwise or, or logical or.
https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.22