title: Java How to flip bits of an array to random values
body: <p>How could you create a method that could flip 2 bits (ranges 00-11 Hence 0-3) in a byte, Randomly! </p>
  
  <p>Example
  <img src="https://i.stack.imgur.com/kpeBq.png" alt="Example"></p>
  
  <pre><code>Coin flip one:   111 01 111
  Coin flip two:   111 11 111
  Coin flip three: 111 01 111
  Coin flip four:  111 10 111
  </code></pre>
  
  <p>What I'm working with</p>
  
  <pre><code>private static void coinFlip(byte theByte)
      {
          Integer mode = new Random().nextInt(3);
          byte value = mode.byteValue();
          byte tmp = value &amp; 255;
              tmp = tmp &gt;&gt; 4;
              tmp = tmp &amp; 3;
             //Point of confusion
             //Now stuff it back in index 5 &amp; 4 ?
      }
  </code></pre>