Java 8: Stream filter method
来源:互联网 发布:java long占几个字节 编辑:程序博客网 时间:2024/06/05 15:20
Sometimes, you might want to work with only a subset of the elements. To do so, you can use the filter method.
The filter method expects a lambda expression as its argument. However, the lambda expression passed to it must always return a boolean value, which determines whether or not the processed element should belong to the resulting Stream object.
For example, if you have an array of strings, and you want to create a subset of it which contains only those strings whose length is more than four characters, you would have to write the following code:
String[] myArray = new String[]{"bob", "alice", "paul", "ellie"};Arrays.stream(myArray) .filter(s -> s.length() > 4) .toArray(String[]::new);
0 0
- Java 8: Stream filter method
- Java 8: Stream map method
- Java 8 Stream API features --- filter/reduce & predicate Interface test method
- Java 8 Stream Filter 过滤null值
- Java Stream(8)(Stream完结)
- Java 8 Stream
- java 8 中的stream
- Java 8 Stream Tutorial
- Java 8 Stream API
- Java 8 Stream 原理
- Java 8 Stream
- Java 8 Stream API
- java8 stream filter()
- Java 8 Stream API详解
- Java 8: Stream Reduction Operations
- Java 8 stream 分组 合并
- JAVA 8 Stream API 对Stream进行分组、分区
- Java Stream
- 表单数组封装成Json对象数组
- python基本数据类型
- 从零开始使用webpack打包工具
- C#菜鸟养成(二)
- CentOS下如何完全卸载MySQL?解决卸载不干净的问题
- Java 8: Stream filter method
- 13. 永无止境:网站的伸缩性架构
- 笔记:linux必备网络基础概念和以太网技术基础
- 算法:使用栈来排序一个栈
- ssl免费证书申请加 nginx配置
- 下拉菜单
- 通知与线程
- LDD设备访问控制
- 【数据结构】哈希表