title: Call constructor with parameter inside Java stream with lambda
body: <p>I want to call a constructor for MySortedSet that takes in a Comparator c as a parameter. How can I modify this to do so?</p>
  
  <pre><code>public MySortedSet&lt;E&gt; subSet(E fromElement, E toElement) {
       return list.stream()
              .filter(x -&gt; (list.indexOf(x) &lt;= list.indexOf(fromElement)
                      &amp;&amp; list.indexOf(x) &lt; list.indexOf(toElement)))
              .collect(Collectors.toCollection(MySortedSet&lt;E&gt; :: new));
  }
  </code></pre>