title: Xor Bytes in Java
body: <p>Java has no support for bit-wise operations on bytes.  I would like to xor two bytes like so:</p>
  
  <pre><code>xoredByte = byte1 ^ byte2;
  </code></pre>
  
  <p>In java this would have to be done as:</p>
  
  <pre><code>xoredByte = (byte) (byte1 ^ byte2);
  </code></pre>
  
  <p>Which compiles to:</p>
  
  <pre><code>xoredByte = (byte) ((int)byte1 ^ (int)byte2);
  </code></pre>
  
  <p>Does this work in all cases?  What I mean is, are these equivalent statements?</p>
  
  <p>If not, what would the code be to perform this operation?</p>