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?
public MySortedSet<E> subSet(E fromElement, E toElement) {
return list.stream()
.filter(x -> (list.indexOf(x) <= list.indexOf(fromElement)
&& list.indexOf(x) < list.indexOf(toElement)))
.collect(Collectors.toCollection(MySortedSet<E> :: new));
}
You can’t use method references if you want to pass additional captured values as parameters. You will have to use a lambda expression instead:
=>