因此,问题在于能够结合多种警告抑制,使每个项目都不需要它自己的@SuppressWarnings注释。
@SuppressWarnings
因此,例如:
public class Example public Example() { GO go = new GO(); // unused .... List<String> list = ( List<String> ) go.getList(); // unchecked } ... // getters/setters/other methods }
现在,@SuppressWarnings我不想在班级针对这两个警告设置两个警告,而是这样:
@SuppressWarnings( "unused", "unchecked" ) public class Example public Example() { GO go = new GO(); // unused - suppressed .... List<String> list = ( List<String> ) go.getList(); // unchecked - suppressed } ... // getters/setters/other methods }
但这不是有效的语法,有没有办法做到这一点?
使用以下内容: @SuppressWarnings({"unused", "unchecked"})
@SuppressWarnings({"unused", "unchecked"})