美文网首页
Java代码中常见到的注释@SuppressWarnings("

Java代码中常见到的注释@SuppressWarnings("

作者: CJL181 | 来源:发表于2019-08-03 18:01 被阅读0次

@SuppressWarnings("unchecked") 告诉编译器忽略 unchecked 警告信息,如使用 List,ArrayList 等未进行参数化产生的警告信息。

// 参数化必须在List加上 <String>
ArrayList<String> stringList= new ArrayList<String>();
stringList.add("伪字符串");
// 经过参数化后,以下语句就不必进行强转了
String s = (String)stringList.get(0);

相关文章

网友评论

      本文标题:Java代码中常见到的注释@SuppressWarnings("

      本文链接:https://www.haomeiwen.com/subject/wpxsdctx.html