What does the ^ operator do in Java?

What function does the ^ (caret) operator serve in Java?

When I try this:

int a = 5^n;

…it gives me:

for n = 5, returns 0
for n = 4, returns 1
for n = 6, returns 3

…so I guess it doesn’t perform exponentiation. But what is it then?

19 Answers
19

Leave a Comment