List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); IntSummaryStatistics stats = numbers .stream() .mapToInt((x) -> x) .summaryStatistics(); Stream<Integer> s=numbers.stream() .filter(e -> e<=5); // .forEach(e -> System.out.println(e)); System.out.println(s.toArray().length); System.out.println("List中最大的数字 : " + stats.getMax()); System.out.println("List中最小的数字 : " + stats.getMin());
java 拉姆的表达式 过滤int数组,获取数组中的最大值,最小值,获取指定条件的数据个数,遍历符合条件数据
最新推荐文章于 2022-11-23 17:21:37 发布