因此,问题在于能够组合多个警告抑制,以便每个项目都不需要它自己的@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“})
—
Raj