Primitive stream vs object stream and actual boxing that occurs
<p>So I understand you can have object streams, i.e. <code>Stream&lt;T&gt;</code> and specialist primitive streams, e.g. <code>IntStream</code>, <code>DoubleStream</code>, etc. One of the benefits of the latter is to avoid autoboxing. </p>

<p>Also if we take <code>IntStream</code> as an example, it has specialised operations such as filter that accepts an <code>IntPredicate</code>.</p>

<p>I wondered if I had an <code>IntStream</code> vs a <code>Stream&lt;Integer&gt;</code> at which point you're saving on boxing, e.g.</p>

<pre><code>intstream.filter(x -&gt; x &gt;= 50).forEach(x -&gt; System.out.println(x));
</code></pre>

<p>vs</p>

<pre><code>stream.filter(x -&gt; x &gt;= 50).forEach(x -&gt; System.out.println(x));
</code></pre>

<p>In the first example, there is no boxing or unboxing that I can see. In the second example where is the boxing / unboxing occurring? Because if stream is a <code>Stream&lt;Integer&gt;</code> and the filter accepts a <code>Predicate&lt;Integer&gt;</code> then surely there's no need to box/unbox, and the same for <code>IntConsumer</code> vs <code>Consumer&lt;T&gt;</code>?</p>