title: How to use Java Stream map for mapping between different types?
body: <p>I have two arrays of equal size:</p>
  
  <ol>
  <li><code>int[] permutation</code></li>
  <li><code>T[] source</code></li>
  </ol>
  
  <p>I want to do smth like this</p>
  
  <pre><code>Arrays.stream(permutation).map(i -&gt; source[i]).toArray();
  </code></pre>
  
  <p>But it won't work saying: <em>Incompatible types: bad return type in lambda expression</em></p>