警告: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<>();
改后警告消失。