Stream是一个接口,而Stream<T> limit(long maxSize);方法并非静态方法,为什么可以直接调用呢?如以下代码:
public class Demo {
public static void main(String[] args) {
String[] arr = {"张三","李四","王五"};
Stream<String> stream = Stream.of(arr);
Stream<String> stream1 = stream.limit(2);
}
}
函数式编程
隔江千里
相关分类