没有合适的资源?快使用搜索试试~ 我知道了~
DK1.8 新特性使用详解.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 73 浏览量
2022-06-28
21:44:17
上传
评论
收藏 21KB DOCX 举报
温馨提示
试读
7页
定义过滤方法: public List<Product> filterProductByPredicate(List<Product> list,MyPredicate<Product> mp){ List<Product> prods = new ArrayList<>(); for (Product prod : list){ if (mp.test(prod)){ prods.add(prod); } } return prods; }
资源推荐
资源详情
资源评论
DK1.8 新特性使用详解
Lambda 表达式
函数式接口
*方法引用和构造器调用
Stream API
接口中的默认方法和静态方法
新时间日期 API
Lambda 表达式
定义过滤方法:
public List<Product> filterProductByPredicate(List<Product>
list,MyPredicate<Product> mp){
List<Product> prods = new ArrayList<>();
for (Product prod : list){
if (mp.test(prod)){
prods.add(prod);
}
}
return prods;
}
使用 lambda 表达式进行过滤
@Test
public void test4(){
List<Product> products = filterProductByPredicate(proList, (p) ->
p.getPrice() < 8000);
for (Product pro : products){
System.out.println(pro);
资源评论
小兔子平安
- 粉丝: 210
- 资源: 1940
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功