Ray 发表于 2018-8-5 19:55:05

空的列表在stream中的allMatch和noneMatch均返回true

@Test
    public void test() {
      List<String> list = new ArrayList<>();
      System.out.println("allMatch:" + list.stream().allMatch(o -> StringUtils.length(o) > 1));
      System.out.println("noneMatch:" + list.stream().noneMatch(o -> StringUtils.length(o) > 1));
    }
allMatch:true
noneMatch:true
页: [1]
查看完整版本: 空的列表在stream中的allMatch和noneMatch均返回true