Eclipse 询问 Replace the type specification in this constructor call with the diamond operator ('<>')
时是什么意思? ,既然所说的运算符(operator)已经在那里了?
然后我将光标放在蓝色下划线的内容上,然后按 F2 了解更多信息,然后我收到此消息 ( Replace the type specification in this constructor call with the diamond operator ('<>')
):
如果我删除Object
从内部<>
,Eclipse还是不高兴:
编辑
我们确保
-
java.util.List
已导入 - 更改已保存
-
Project -> Clean...
命令已应用
蓝色警告仍然不会消失。
最佳答案
这似乎是 SonarLint 中的一个错误的钻石操作符检查器,而不是 Eclipse JDT:请参阅 the source code of SonarLint that contains the message .
另请参阅:SonarJava Rule 2293: The diamond operator ("<>") should be used
解决方案:
禁用SonarJava规则2293并使用Eclipse警告泛型类型>改为冗余类型参数(1.7 或更高)。
关于java - Java 项目中的 Eclipse 警告 "Replace the type specification in this constructor call with the diamond operator (' < >')",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47396437/