title: In java, why the byte type can use &0xff to do the unsigned right shift operation?
body: <p>I know, in Java, byte type, before doing a right shift operation, will convert into the int type firstly. </p>
  
  <p>So in Java, we will get a incorrect answer for byte type's >>> operation.</p>
  
  <p>For example, </p>
  
  <pre><code>byte b=(byte)0xf1;
  byte c=(byte)(b&gt;&gt;4);
  byte d=(byte)(b&gt;&gt;&gt;4);
  byte e=(byte)((b&amp;0xff)&gt;&gt;4);
  </code></pre>
  
  <p>d's answer equal to c. but e's anser is correct. I can't think of the reason.</p>
  
  <p>Thanks</p>