import java.util.*; import java.util.function.BiConsumer; import java.util.function.Supplier; import java.util.stream.Stream; class MyTest { { Stream stream = Stream.of("a", "b", "c", "d"); Set set = stream.collect(()->new TreeSet(), TreeSet::add, TreeSet::addAll); } } abstract class Simplified { void m(final BiConsumer, TreeSet> addAll) { Set set = collect(TreeSet:: add, addAll); } abstract R collect(BiConsumer accumulator, BiConsumer combiner); }