jdk8新特性
荔枝怎么荔枝
这个作者很懒,什么都没留下…
展开
-
简单的StreamAPI的使用练习
给定一个数字列表,如何返回一个由每个数的平方构成的列表呢? 例如,给定【1,2,3,4,5】, 应该返回【1,4,9,16,25】 public class Exer1 { public static void main(String[] args) { List<Integer> asList = Arrays.asList(1,2,3,4,5,6); Stream<Integer> stream = asList.stream(); stream.map(a -&原创 2022-03-25 09:17:52 · 248 阅读 · 0 评论 -
简单的Lambda表达式练习
1. 调用 Collections.sort()方法,通过定制排序比较两个 Employee(先按 年龄比,年龄相同按姓名 比),使用 Lambda 表达式作为参数传递。 public class Exer1 { public static void main(String[] args) { Employee e1 = new Employee(1001, "马化腾", 34, 6000.38); Employee e2 = new Employee(1002, "马云", 12, 987.原创 2022-03-25 09:01:14 · 413 阅读 · 0 评论