消除unchecked cast

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

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

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

加上具体的类型

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

或者

在方法前面加上

@SuppressWarnings("unchecked")
原文地址:https://www.cnblogs.com/baby123/p/13666053.html