我是靠谱客的博主 任性盼望,这篇文章主要介绍Lambda常用语法,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
基础数据 List<Item> list = new ArrayList<>(); list.add(new Item(11,"aa")); list.add(new Item(10,"bb")); list.add(new Item(18,"cc")); list.add(new Item(9,"dd")) 1.根据id排序 List<Item> collect= list.stream().sorted(Comparator.comparing(Item::getId)).collect(Collectors.toList()); 2.集合遍历 collect.forEach(e->{ System.out.println(e.getId()+"_"+e.getName()); }); 3.移除list中某个元素 list.removeIf(e -> e.getId() == 10); 4.快速打印 ArrayList<Integer> list = new ArrayList<>(); Collections.addAll(list, 1,2,3,4,5); list.forEach(System.out::println);

最后

以上就是任性盼望最近收集整理的关于Lambda常用语法的全部内容,更多相关Lambda常用语法内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部