title: Convert a Object[] of booleans to a boolean[] using streams
body: <p>I can do the conversion with code like this:</p>
  
  <pre><code>Object[] array = (Object[]) message.get(key);
  boolean[] result = new boolean[array.length];
  for (int i = 0; i &lt; array.length; i++) {
      result[i] = (boolean) array[i];
  }
  </code></pre>
  
  <p>But, I was think that is possible to do the same conversion using Java 8 streams. I start to code something like this:</p>
  
  <pre><code>boolean[] =  Arrays.stream(array)
                     .map(Boolean.class::cast)
                     .map(Boolean::booleanValue)
                     .toArray()
  </code></pre>
  
  <p>But this code doesn't work. Compiler says </p>
  
  <pre><code>incompatible types: java.lang.Object[] cannot be converted to boolean[]
  </code></pre>
  
  <p>I'm trying to understand what is the problem with the code. I think that <code>map(Boolean::booleanValue)</code> would return a stream of boolean values I can collect with <code>toArray</code>.</p>