/*
* Stream是数据渠道,用于操作数据源(集合,数组等)所生成的元素序列。
* Stream不会改变源数据,每次处理都会返回一个持有结果的新stream
* 类似于SQL语句对数据库的查询
* Stream是个延迟操作
*
* 操作步骤
* 1.建立一个Stream数据渠道,即指定数据源
* 2.中间操作可以是0~n步
*
* 3.取结果
*/
public class TestStream {
@Test
public void t2(){
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("1");
arrayList.add("2");
arrayList.add("3");
//Stream<String> stream = arrayList.stream();
Stream<ArrayList<String>> stream = Stream.of(arrayList);
stream.forEach(t -> System.out.println(t));
}
}
Java1.8的Stream---demo
原创
©著作权归作者所有:来自51CTO博客作者Zy开发的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:Java类的初始化
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java之Stream流
Stream是一种处理集合(Collection)数据的方式。Stream可以让我们以一种更简洁的方式对集合进行过滤、映射、排序等操作。
System 数据 数组 Stream Java基础 -
Stream:java1.8新特性
Java1.8 个人总结
List 数据 初始化