What function does the ^ (caret) operator serve in Java?
^
When I try this:
int a = 5^n;
...it gives me:
As already stated by the other answer(s), it's the "exclusive or" (XOR) operator. For more information on bit-operators in Java, see: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op3.html