变量未使用报黄线警告: @SuppressWarnings("unused")去除
all (抑制所有警告)
deprecation (抑制过期方法警告)
null (忽略对null的操作)
serial (忽略在serializable类中没有声明serialVersionUID变量)
unchecked (抑制没有进行类型检查操作的警告)
unused (抑制没被使用过的代码的警告)
=============================================
我很好奇这个注解可以传的参数到底是在哪里看到的, 注释中也看到一个{@code "unchecked"}, 有知道的大神求告知, 嘻嘻 !!!
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
public @interface SuppressWarnings {
/**
* The set of warnings that are to be suppressed by the compiler in the
* annotated element. Duplicate names are permitted. The second and
* successive occurrences of a name are ignored. The presence of
* unrecognized warning names is <i>not</i> an error: Compilers must
* ignore any warning names they do not recognize. They are, however,
* free to emit a warning if an annotation contains an unrecognized
* warning name.
*
* <p> The string {@code "unchecked"} is used to suppress
* unchecked warnings. Compiler vendors should document the
* additional warning names they support in conjunction with this
* annotation type. They are encouraged to cooperate to ensure
* that the same names work across multiple compilers.
* @return the set of warnings to be suppressed
*/
String[] value();
}
SuppressWarnings()
最新推荐文章于 2024-02-20 22:38:37 发布