12
Tôi muốn gọi hàm tạo cho MySortedSet lấy trong một Comparator c làm tham số. Làm thế nào tôi có thể sửa đổi điều này để làm như vậy?Gọi hàm tạo với tham số bên trong luồng Java với lambda
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));
}