My code is as following:
char ch = t.charAt(t.length() - 1);
// result of XOR of two char is Integer.
for(int i = 0; i < s.length(); i++){
ch = ch^s.charAt(i);
ch = ch^t.charAt(i);
}
return ch;
it throws error
Line 6: error: incompatible types: possible lossy conversion from int to char ch = ch^s.charAt(i);
Line 7: error: incompatible types: possible lossy conversion from int to char ch = ch^t.charAt(i);
2 errors
However, When I change
ch = ch^s.charAt(i);
ch = ch^t.charAt(i);
to
ch ^= s.charAt(i);
ch ^= t.charAt(i);
Then, my code can work.
Are '^=' and '* = ^' different?? Why I search this question about '^=', it says they are same??