java中 @SuppressWarnings 注解的使用(小白某度直译)

在代码的编写中,我们经常会发现一段代码忽然报错,但是运行编译时可以通过的 , 那么你就可以使用 @SuppressWarnings

@SuppressWarnings 是什么?

https://zhidao.baidu.com/question/297231941.html  (感谢大佬)

能干什么?

用于抑制编译器产生警告信息。 

 

例如:

在没有加入注解的时候会报警告 

java中 @SuppressWarnings 注解的使用(小白某度直译)

加入后:

java中 @SuppressWarnings 注解的使用(小白某度直译)

 

 

下面是应用类型(英文与翻译软件直译): 

 

all  to suppress all warnings (all)
boxing / to suppress warnings relative to boxing/unboxing operations (Be similar to Integer i = new Integer(10) ==Integer i = 10) (boxing)
cast    to suppress warnings relative to cast operations 
dep-ann    to suppress warnings relative to deprecated annotation
deprecation    to suppress warnings relative to deprecation
fallthrough     to suppress warnings relative to missing breaks in switch statements
finally     to suppress warnings relative to finally block that don’t return
hiding    to suppress warnings relative to locals that hide variable
incomplete-switch     to suppress warnings relative to missing entries in a switch statement (enum case)
nls     to suppress warnings relative to non-nls string literals
null    to suppress warnings relative to null analysis
rawtypes    to suppress warnings relative to un-specific types when using generics on class params
restriction    to suppress warnings relative to usage of discouraged or forbidden references
serial    to suppress warnings relative to missing serialVersionUID field for a serializable class
static-access    o suppress warnings relative to incorrect static access
synthetic-access      to suppress warnings relative to unoptimized access from inner classes
unchecked     to suppress warnings relative to unchecked operations
unqualified-field-access    to suppress warnings relative to field access unqualified
unused    to suppress warnings relative to unused code

 

取消所有警告(全部)

装箱/取消装箱操作相关的警告(类似于integer i=new integer(10)==integer i=10)(装箱)

强制转换以禁止与强制转换操作相关的警告

dep ann取消与已弃用批注相关的警告

取消预测以取消与取消预测相关的警告

通过fallthrough取消与switch语句中缺少中断相关的警告

最后抑制与不返回的finally块相关的警告

hidden隐藏与隐藏变量的局部变量相关的警告

不完整的开关,用于禁止与switch语句中缺少的条目相关的警告(枚举大小写)

NLS禁止与非NLS字符串文本相关的警告

空以取消与空分析相关的警告

rawtypes用于在类参数上使用泛型时取消与非特定类型相关的警告

禁止禁止使用不鼓励或禁止引用的警告的限制

Serial取消与可序列化类的缺少serialversionID字段相关的警告

静态访问o取消与不正确的静态访问相关的警告

禁止与内部类的未优化访问相关的警告的合成访问

取消选中可取消显示与未选中操作相关的警告

非限定字段访问抑制与字段访问非限定相关的警告

未用于取消与未使用代码相关的警告

 

 


小白一个,不足之处多多指教