【一天一坑】空数组,使用 allMatch 默认返回true

复制代码
List<Integer> list = new ArrayList<>();
boolean flag = list.stream().allMatch(e -> e > 0);
//flag = true
复制代码
/**
 * Returns whether all elements of this stream match the provided predicate.
 * May not evaluate the predicate on all elements if not necessary for
 * determining the result.  If the stream is empty then {@code true} is
 * returned and the predicate is not evaluated.
 *
 * <p>This is a <a href="package-summary.html#StreamOps">short-circuiting
 * terminal operation</a>.
 *
 * @apiNote
 * This method evaluates the <em>universal quantification</em> of the
 * predicate over the elements of the stream (for all x P(x)).  If the \* stream is empty, the quantification is said to be \<em\>vacuously \* satisfied\</em\> and is always {@code true} (regardless of P(x)).
 *
 * @param predicate a <a href="package-summary.html#NonInterference">non-interfering</a>,
 *                  <a href="package-summary.html#Statelessness">stateless</a>
 *                  predicate to apply to elements of this stream
 * @return {@code true} if either all elements of the stream match the
 * provided predicate or the stream is empty, otherwise {@code false}
 */
相关推荐
微学AI12 分钟前
国产数据库替代MongoDB的技术实践过程:金仓多模数据库在电子证照系统中的深度应用
数据库·人工智能·1024程序员节
TDengine (老段)21 分钟前
TDengine 数据函数 ROUND 用户手册
java·大数据·数据库·物联网·时序数据库·tdengine·1024程序员节
TDengine (老段)24 分钟前
TDengine 数学函数 RAND 用户手册
java·大数据·数据库·物联网·时序数据库·tdengine·涛思数据
烛阴31 分钟前
循环背后的魔法:Lua 迭代器深度解析
前端·lua
野犬寒鸦35 分钟前
从零起步学习MySQL || 第十章:深入了解B+树及B+树的性能优势(结合底层数据结构与数据库设计深度解析)
java·数据库·后端·mysql·1024程序员节
GZ_TOGOGO39 分钟前
Oracle OCP考试报名常见问题详解
数据库·oracle·ocp认证
睡不醒的猪儿40 分钟前
nginx日志同步阿里云datahub后写入数据库
数据库·nginx·阿里云
元拓数智44 分钟前
现代前端状态管理深度剖析:从单一数据源到分布式状态
前端·1024程序员节
mapbar_front1 小时前
Electron 应用自动更新方案:electron-updater 完整指南
前端·javascript·electron
xie_zhr1 小时前
【PB案例学习笔记】-46在数据窗口中编辑数据
数据库·his·1024程序员节·干货分享·pb·powerbuilder