news 2026/9/6 19:33:10

JDK 9 List.of(...)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
JDK 9 List.of(...)
// JDK 9 写法: List.of(...) // List<Point> polygon = List.of(new Point(0, 0), new Point(0, 4), new Point(4, 4), new Point(4, 0)); // JDK 1.6 写法:使用ArrayList并手动add元素 List<Point> polygon = new ArrayList<Point>(); polygon.add(new Point(0, 0)); polygon.add(new Point(0, 4)); polygon.add(new Point(4, 4)); polygon.add(new Point(4, 0));

JDK 9 List.of(...) JDK 1.6 boolean add(E e);

/** * Appends the specified element to the end of this list (optional * operation). * * <p>Lists that support this operation may place limitations on what * elements may be added to this list. In particular, some * lists will refuse to add null elements, and others will impose * restrictions on the type of elements that may be added. List * classes should clearly specify in their documentation any restrictions * on what elements may be added. * * @param e element to be appended to this list * @return <tt>true</tt> (as specified by {@link Collection#add}) * @throws UnsupportedOperationException if the <tt>add</tt> operation * is not supported by this list * @throws ClassCastException if the class of the specified element * prevents it from being added to this list * @throws NullPointerException if the specified element is null and this * list does not permit null elements * @throws IllegalArgumentException if some property of this element * prevents it from being added to this list */ boolean add(E e);

没有什么为什么,一方面以前做的项目1.6 1.8 要兼容,另一方面代码习惯,明了比简洁还要重要。

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/6 19:32:39

网页视频下载不求人:猫抓浏览器扩展完整使用指南

网页视频下载不求人&#xff1a;猫抓浏览器扩展完整使用指南 【免费下载链接】cat-catch 猫抓 浏览器资源嗅探扩展 / cat-catch Browser Resource Sniffing Extension 项目地址: https://gitcode.com/GitHub_Trending/ca/cat-catch 明早八点的动车&#xff0c;六个小时路…

作者头像 李华
网站建设 2026/9/6 19:20:30

生产质量管理异常报告表:从车间设计到闭环复盘的实战指南

简介&#xff1a;生产质量管理异常报告表.doc是一份面向生产企业质量管控场景的Word模板&#xff0c;适合品质管理、车间班组及现场巡检人员使用&#xff0c;用于在生产过程出现异常时快速记录问题、定位原因并推进改进。模板覆盖异常品质特性、管制标准、超出范围及数量、产品…

作者头像 李华
网站建设 2026/9/6 19:15:40

ARIMA+加权马尔可夫链:误差修正提升时间序列预测精度

简介&#xff1a;这是一篇关于组合时间序列预测模型研究的学术论文PDF&#xff0c;面向机器学习、算法研究与设备状态监测领域工程师&#xff0c;旨在解决单一ARIMA模型预测设备状态参数时存在偏差和不稳定的问题。论文提出引入加权马尔可夫链对ARIMA残差序列进行修正&#xff…

作者头像 李华