title: Java: Check binary value with a mask then get integer
body: <p>Here is my problem: </p>
  
  <p>I have a binary value</p>
  
  <pre><code>101001
  </code></pre>
  
  <p>and a mask</p>
  
  <pre><code>011100
  </code></pre>
  
  <p>I would like to compare them and get the result as an integer. In this case that would give:</p>
  
  <pre><code> 1 **010** 01
   0 **111** 00
  
  = 010 =&gt; 2
  </code></pre>
  
  <p>My first idea consists of dealing with a character array. But I would like to know if there is a better way to achieve this aim in Java?</p>