title: Java - How to Extract Certain Portions of Bits Using Bit Mask?
body: <p>This is the first time I am looking at bitwise operations and bit mask. I have seen some examples using C and C++, but I am looking for clarification using Java. </p>
  
  <p>I have the following 32-bit string</p>
  
  <p>0000 00<strong>00 101</strong>0 0110 0011 1000 0010 0000</p>
  
  <p>But I want to extract bits 21 through 25 in bold (00101) and ignore everything else. In the end, I want my output result to be integer 5 (0101 in binary)</p>
  
  <p>Using bit mask, what approach I could use to get just that bit portion as my output result? </p>