在 idea 编辑器中,把一个Map类型的数据,强制类型转换的时候。
在中不想看到代码的如下警告的解决方法:
警告信息————-
简单警告:
Unchecked call to ‘put(K, V)’ as a member of raw type ‘java.util.HashMap’ less… (Ctrl+F1)
点开查看详细警告:
Unchecked cast: ‘java.lang.Object’ to ‘java.util.HashMap<java.lang.Object>’ less… (Ctrl+F1)
Signals places where an unchecked warning is issued by the compiler, for example:
void f(HashMap map) {
map.put(“key”, “value”);
}
Hint: Pass -Xlint:unchecked to javac to get more details.
去除代码警告的解决方案:
在此方法上面或者那个强制类型转换的上面加上如下一句话。
@SuppressWarnings(“unchecked”)