记录一下Stream流的一个坑

List<String> list = new ArrayList<>();

        boolean a = list.stream().anyMatch("a"::equals); // If the stream is empty then false is returned and the predicate is not evaluated.
        boolean b = list.stream().allMatch("b"::equals); // If the stream is empty then true is returned and the predicate is not evaluated.
        boolean c = list.stream().noneMatch("c"::equals); // If the stream is empty then true is returned and the predicate is not evaluated.

        System.out.println("a = " + a);
        System.out.println("b = " + b);
        System.out.println("c = " + c);

image

posted @ 2022-11-10 13:36  我也有梦想呀  阅读(69)  评论(0)    收藏  举报