代码
提交代码
import java.util.List;
import java.util.stream.Stream;
import java.util.stream.Collectors;
import java.util.TreeSet;
public class Test{
public static void main(String...s){
List<String> collected = Stream.of("a","b","c","c").collect(Collectors.toList());
TreeSet<String> treeSet = collected.stream().collect(Collectors.toCollection(TreeSet::new));
System.out.println(collected);
System.out.println(treeSet);
}
}
运行结果