【一天一坑】空数组,使用 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}
 */
相关推荐
坚定信念,勇往无前2 小时前
mongodb的日志分割
数据库·mongodb
ℋᙚᵐⁱᒻᵉ鲸落4 小时前
移动端滑动手势冲突:overflow: auto导致外层横向滑动失效
前端·javascript·css·vue.js·html
oradh5 小时前
Oracle TX 锁 Mode 4(Share)问题排查总结
数据库·oracle·tx 锁 mode 4·oracle tx 锁
yi.Ist6 小时前
数据定义语言-DDL操作
数据库·学习·mysql·oracle·大海豚
默_笙6 小时前
🎃 前端学了 Next.js,后端该学啥?NestJS 就是 Node 版的蜜雪冰城
前端·javascript
前端snow7 小时前
ai agent --- 实现 openclaw 定时间效果
前端
码云之上7 小时前
换模型之后,Chatbot 为什么要自己做 compact?
前端·agent·前端工程化
2601_963282777 小时前
工程项目、政企采购为什么优先选择对讲机批量采购?
数据库
星栈7 小时前
自定义 UI-UX-Pro-Max 的 CSV 知识库,把 AI 生成的后台拉回行业该有的样子
前端·agent·weui
Doraemomo7 小时前
SQLite数据库
数据库·sqlite