package cn.bunny.stream; import java.util.stream.Stream; public class StreamExample04 { public static void main(String[] args) { // 找到第一个数字 Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9) .findFirst() .ifPresent(System.out::println); // 获取任意一个数字 Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9) .findAny() .ifPresent(System.out::println); } }