title: Why does Collections.UnmodifiableMap.UnmodifiableEntrySet override the stream() method?
body: <p>While looking at the source code, I could see that the <code>stream()</code> method has been overridden in <code>Collections.UnmodifiableMap.UnmodifiableEntrySet</code>. But the code seems to be identical to <code>Collection.stream()</code> except the return type in <code>Collections.UnmodifiableMap.UnmodifiableEntrySet.stream()</code> is more specific to be <code>Stream&lt;Entry&lt;K,V&gt;&gt;</code> rather than just <code>Stream&lt;E&gt;</code> as in <code>Collection.stream()</code>.</p>
  <p>The <code>spliterator()</code> method is different in both classes, but even if <code>stream</code> is not overriden I think that the <code>UnmodifiableEntrySet.spliterator()</code> would be invoked from <code>Collection.stream()</code> if the object is of type <code>UnmodifiableEntrySet</code>.</p>
  <p>So, is there any reason why the <code>stream</code> method was overriden?</p>
  <p><strong>Collection.java</strong></p>
  <pre class="lang-java prettyprint-override"><code>@Override
  default Spliterator&lt;E&gt; spliterator() {
      return Spliterators.spliterator(this, 0);
  }
   
  default Stream&lt;E&gt; stream() {
      return StreamSupport.stream(spliterator(), false);
  }
  </code></pre>
  <p><strong>Collections.UnmodifiableMap.UnmodifiableEntrySet.java</strong></p>
  <pre class="lang-java prettyprint-override"><code>@SuppressWarnings(&quot;unchecked&quot;)
  public Spliterator&lt;Entry&lt;K,V&gt;&gt; spliterator() {
      return new UnmodifiableEntrySetSpliterator&lt;&gt;(
          (Spliterator&lt;Map.Entry&lt;K, V&gt;&gt;) c.spliterator());
  }
  
  @Override
  public Stream&lt;Entry&lt;K,V&gt;&gt; stream() {
      return StreamSupport.stream(spliterator(), false);
  }
  </code></pre>