【一天一坑】空数组,使用 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}
 */
相关推荐
梁bk8 小时前
Redis 通信协议(RESP)
数据库·redis·缓存
思成不止于此9 小时前
MySQL 约束详解:保证数据完整性的核心机制
数据库·笔记·学习·mysql
脾气有点小暴9 小时前
详解 HTML Image 的 mode 属性:图像显示模式的灵活控制
前端·html·uniapp
理想三旬9 小时前
数据定义:模式、表、索引
数据库
c***87199 小时前
讲解进阶之路:模块、包和异常处理-上篇
数据库·redis·哈希算法
0思必得09 小时前
[Web自动化] 开发者工具性能(Performance)面板
运维·前端·自动化·web自动化·开发者工具
!chen9 小时前
Oracle分区表+本地索引 核心优化方案
数据库·oracle
心灵的制造商9 小时前
el-tree左侧新增类别和删除类别实例代码
前端·javascript·vue.js
叽里咕噜怪9 小时前
MySQL-读写分离实验
数据库·mysql
冴羽9 小时前
不知道怎么写 Nano Banana Pro 提示词?分享你一个结构化示例,复刻任意图片
前端·人工智能·aigc