进阶day07-Stream流中的常用方法_count

This commit is contained in:
2026-03-14 15:23:59 +08:00
parent be4298f311
commit 8bf20dcf3d

View File

@@ -0,0 +1,14 @@
package com.inmind.stream03;
import java.util.stream.Stream;
/*
Stream流中的常用方法_count
获取流中元素的个数
*/
public class CountDemo20 {
public static void main(String[] args) {
Stream<Integer> stream = Stream.of(1, 2, 4);
System.out.println(stream.count());//3
}
}