3-JavaSe-1-stream-1-流库特征

1.parallelStream可以让流库以并行方式来执行过滤和计数。

String content=new String(Files.readAllBytes(Paths.get("D:\test\alice.txt")), StandardCharsets.UTF_8);//read file into string
List<String> words = Arrays.asList(content.split(" "));
long count2 = words.parallelStream() //可以让流库并行的执行过滤和计数
.filter(w -> w.length() > 5).count();

2.使用流,可以说明想要完成什么任务,而不是说明如何去使用它。

3.流不会改变,总会新建(中间流转换操作)

原文地址:https://www.cnblogs.com/ywdjx/p/3-JavaSe-1-stream-1.html