今天看到有些代码上老是出现unchecked cast,看着很不爽,就像去掉它们

消除unchecked cast

使用maven打包也会有如下提示

[INFO] /E:/project/api/src/main/java/com/abc/controller/ApiAAAController.java: E:\project\api\src\main\java\com\abc\controller\ApiAAAController.java使用了未经检查或不安全的操作。
[INFO] /E:/project/api/src/main/java/com/abc/controller/ApiAAAController.java: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。

加上具体的类型

List<String> guids = new ArrayList<String>();
guids.add("111");

 

 

或者

消除unchecked cast

在方法前面加上

@SuppressWarnings("unchecked")

 

相关文章:

  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-11-01
  • 2022-01-07
  • 2021-09-13
猜你喜欢
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
相关资源
相似解决方案