警告:“explicit type argument xx can be replaced with......”

警告:explicit type argument xx can be replaced with<>

开发工具 IDEA

开发时有警告信息: explicit type argument xx can be replaced with<>
完整的:

explicit type argument xxx can be replaced with<>, 
inspection info: reports all new expressions with type arguments
which can be replaced with diamond type
such<> syntax is not support under java 1.6 or earlier JVMs`在这里插入代码片`

大概意思如下:
显式类型参数xx可以替换为<>,检查信息:报告所有带有类型参数的新表达式,
这些表达式可以用菱形类型替换,因此<>语法不支持java 1.6或更早版本的JVM

在这里插入图片描述
问题就出在 List<Entity> list = new ArrayList<Entity>();
这种泛型只需写在List<>里边即可。 List里边声明了泛型以后,再在ArrayList里边声明也重复冗余的。

改成如下:

List<Entity> list = new ArrayList<>();

改后警告消失。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值