问题描述
anyMatch操作如果找到一个元素,则返回true; noneMatch操作如果找到一个匹配的元素,则返回false.
The anyMatch operation will return true if it finds an element - the noneMatch operation will return false it if finds a matching element.
anyMatch操作如果找不到匹配的元素将返回false-noneMatch操作如果找不到匹配的元素将返回true.
The anyMatch operation will return false if it finds no matching element - the noneMatch operation will return true if finds no matching element.
因此,除了进行这两项操作外,我们还不能只做一项操作,否则我会丢失什么吗?从本质上讲,anyMatch返回false是评估noneMatch谓词真实性的一种方法.
Therefore, instead of having both of these operations, could we not just do with one, or am I missing something? In essence, anyMatch returning false is a way of evaluating the truth of noneMatch's predicate.
推荐答案
同样的原因,您拥有a != b
,而不是仅支持! (a == b)
:
Same reason you have a != b
, instead of only supporting ! (a == b)
:
- 易于使用.
- 目的明确.
这篇关于Java流-同时具有anyMatch和noneMatch操作的目的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!