title: Convert List<Boolean> to byte [ ] array
body: <p>I have a list of booleans which I want to convert Byte [] arrays.I try to convert List to byte[] arrays but I have a mistake.This is my code </p>
  
  <pre><code> List&lt;Boolean&gt; list = model.getBooleanData();
                 boolean[] inputSleep = new boolean[list.size()];
  
                 byte[] toReturn = new byte[inputSleep.length / 8];
                 for (int entry = 0; entry &lt; toReturn.length; entry++) {
                     for (int bit = 0; bit &lt; 8; bit++) {
                         if (inputSleep[entry * 8 + bit]) {
                             toReturn[entry] |= (128 &gt;&gt; bit);
                         }
                     }
                 }
  </code></pre>
  
  <p>I get all Booleans and checked but I try to this all Booleans false.Thanks your helps.How can I correctly convert List to byte[] arrays?</p>