@SuppressWarnings注解学习

基本了解

这个注解对于强迫症的我简直太爽了!!!

作用: 给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默,即不再提示。

注解目标

类、字段、函数、函数入参、构造函数和函数的局部变量

示例说明

类上
@SuppressWarnings("all")
public class MyTest {
    public static void main(String[] args) {
        System.out.println("我这么欠揍,你来打我啊!");
    }
}
变量上
public class MyTest {

    @SuppressWarnings("all")
    private String name="张三";

    public static void main(String[] args) {
        System.out.println("我这么欠揍,你来打我啊!");
    }
}

参数介绍

参数代表的含义mean
all'suppress all warnings'‘抑制所有警告’
boxing'suppress warnings relative to boxing/unboxing operations'抑制与装箱/拆箱操作相关的警告
cast'suppress warnings relative to cast operations'禁止与强制转换操作相关的警告
dep-ann'suppress warnings relative to deprecated annotation'禁止与已弃用注释相关的警告
deprecation'suppress warnings relative to deprecation'抑制与deprecation相关的警告
fallthrough'suppress warnings relative to missing breaks in switch statements'抑制与switch语句中缺少break相关的警告
finally'suppress warnings relative to finally block that don’t return'抑制相对于finally block不返回的警告
hiding'suppress warnings relative to locals that hide variable'抑制与隐藏变量的局部变量相关的警告
incomplete-switch'suppress warnings relative to missing entries in a switch statement (enum case)'抑制与switch语句中缺少条目相关的警告(enum情况)
nls'suppress warnings relative to non-nls string literals'禁止与非nls字符串字面值相关的警告
null'suppress warnings relative to null analysis'抑制与null分析相关的警告
rawtypes'suppress warnings relative to un-specific types when using generics on class params'在类参数上使用泛型时,禁止与非特定类型相关的警告
restriction'suppress warnings relative to usage of discouraged or forbidden references'抑制与不鼓励或禁止引用的使用相关的警告
serial'suppress warnings relative to missing serialVersionUID field for a serializable class'抑制与可序列化类缺少serialVersionUID字段相关的警告
static-access'suppress warnings relative to incorrect static access'抑制与不正确静态访问相关的警告
synthetic-access'suppress warnings relative to unoptimized access from inner classes'抑制与内部类未优化访问相关的警告
unchecked'suppress warnings relative to unchecked operations'抑制与未选中操作相关的警告
unqualified-field-access'suppress warnings relative to field access unqualified'抑制有关字段访问不合格的警告
unused'suppress warnings relative to unused code'抑制相对于未使用代码的警告
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Double@加贝

我这么欠揍,你来打赏我啊!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值