因此,问题在于能够组合多个警告 suppress ,这样每个条目就不需要自己的@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
}
但这不是一个有效的语法,有没有办法做到这一点?