title: What do "& 0xFF" and ">>>" shifting do?
body: <p>I am trying to understand the below code. </p>
  
  <p>The method getKey() returns a string, and getDistance() returns a double. The code is a taken from a class which is meant to hold String (the key) and Double (the distance) pairs. </p>
  
  <p>To be more specific I am unsure as to what the lines that do the shifting do. </p>
  
  <pre><code>public void serialize (byte[] outputArray) {
  
      // write the length of the string out
      byte[] data = getKey().getBytes ();
      for (int i = 0; i &lt; 2; i++) {
        outputArray[i] = (byte) ((data.length &gt;&gt;&gt; ((1 - i) * 8)) &amp; 0xFF);
      }
  
      // write the key out
      for (int i = 0; i &lt; data.length; i++) {
        outputArray[i + 2] = data[i];   
      }
  
      // now write the distance out
      long bits = Double.doubleToLongBits (getDistance());
      for (int i = 0; i &lt; 8; i++) {
        outputArray[i + 2 + data.length] = (byte) ((bits &gt;&gt;&gt; ((7 - i) * 8)) &amp; 0xFF);
      }
  }
  </code></pre>
  
  <p>Any help would be very appreciated. </p>