繁体   English   中英

Java-Stream - 行为差异:空 stream 的 anyMatch 与 allMatch 和 noneMatch

[英]Java-Stream - Difference in behaviour: anyMatch vs. allMatch and noneMatch for an empty stream

虽然Stream#anyMatch为空 stream 返回false ,但Stream#allMatchStream#noneMatch为空 stream 返回true

为什么空 Stream 的allMatch anyMatch noneMatch的行为不同?

Stream#anyMatch在 stream 的元素上评估谓词的存在量化 对于空集,存在量化总是评估为false

另一方面, Stream#allMatch评估 stream 元素上谓词的全称量化Stream#noneMatch评估 stream 元素上否定谓词的全称量化。 对于空集,全称量化总是为true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM