空的列表在stream中的allMatch和noneMatch均返回true
@Testpublic 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]