I am not 100% sure what you are asking, but hopefully this helps:
Java forces both operands to int. That is why the result is int.
http://java.comsci.us/syntax/expression/bitwisexor.html
therefore, your shorts will be automatically converted to int, and the XOR operation will be performed very efficiently on integer operands.
If one of the operands is long, both types are instead forced to length. However, this does not apply to your case.
On the bottom line, given that both of your entries are short, if you need a short result, the most efficient thing is
short result = (short) (operandA ^ operandB);
source share