【一天一坑】空数组,使用 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}
 */
相关推荐
u0109272711 天前
RESTful API设计最佳实践(Python版)
jvm·数据库·python
0思必得01 天前
[Web自动化] Selenium处理动态网页
前端·爬虫·python·selenium·自动化
qq_192779871 天前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
东东5161 天前
智能社区管理系统的设计与实现ssm+vue
前端·javascript·vue.js·毕业设计·毕设
u0109272711 天前
使用Plotly创建交互式图表
jvm·数据库·python
爱学习的阿磊1 天前
Python GUI开发:Tkinter入门教程
jvm·数据库·python
catino1 天前
图片、文件的预览
前端·javascript
tudficdew1 天前
实战:用Python分析某电商销售数据
jvm·数据库·python
sjjhd6521 天前
Python日志记录(Logging)最佳实践
jvm·数据库·python
Configure-Handler1 天前
buildroot System configuration
java·服务器·数据库