title: How to validate value of bit in byte array in java
body: <p>I have a byte array, for example 400 bytes.... and then a position of a bit, for example 6. How can I check if the value of this bit is 1? So in my example, the return value will be true.</p>
  
  <p>example:</p>
  
  <pre><code>final byte[] b = new byte[] { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
  </code></pre>
  
  <p>what is 00000100....
  pos = 6
  result  = true</p>