日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

@SuppressWarnings注解用法

發布時間:2025/4/16 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 @SuppressWarnings注解用法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

@SuppressWarnings注解主要用在取消一些編譯器產生的警告對代碼左側行列的遮擋,有時候這會擋住我們斷點調試時打的斷點。 如圖所示:

這時候我們在方法上加上@SuppressWarnings注解就可以消除這些警告的產生,注解的使用有三種:1. @SuppressWarnings("unchecked") [^ 抑制單類型的警告] 2. @SuppressWarnings("unchecked","rawtypes") [^ 抑制多類型的警告] 3. @SuppressWarnings("unchecked") [^ 抑制所有類型的警告] *** > 通過源碼分析可知@SuppressWarnings其注解目標為類、字段、函數、函數入參、構造函數和函數的局部變量。建議把注解放在最近進警告發生的位置。 下面列舉警告關鍵字: 關鍵字用途
allto suppress all warnings (抑制所有警告)
boxingto suppress warnings relative to boxing/unboxing operations (抑制裝箱、拆箱操作時候的警告)
castto suppress warnings relative to cast operations (抑制映射相關的警告)
dep-annto suppress warnings relative to deprecated annotation (抑制啟用注釋的警告)
deprecationto suppress warnings relative to deprecation (抑制過期方法警告)
fallthroughto suppress warnings relative to missing breaks in switch statements (抑制確在switch中缺失breaks的警告)
finallyto suppress warnings relative to finally block that don’t return (抑制finally模塊沒有返回的警告)
hidingto suppress warnings relative to locals that hide variable(抑制相對于隱藏變量的局部變量的警告)
incomplete-switchto suppress warnings relative to missing entries in a switch statement (enum case)(忽略沒有完整的switch語句)
nlsto suppress warnings relative to non-nls string literals( 忽略非nls格式的字符)
nullto suppress warnings relative to null analysis( 忽略對null的操作)
rawtypesto suppress warnings relative to un-specific types when using generics on class params( 使用generics時忽略沒有指定相應的類型)
restrictionto suppress warnings relative to usage of discouraged or forbidden references( 抑制禁止使用勸阻或禁止引用的警告)
serialto suppress warnings relative to missing serialVersionUID field for a serializable class( 忽略在serializable類中沒有聲明serialVersionUID變量)
static-accessto suppress warnings relative to incorrect static access( 抑制不正確的靜態訪問方式警告)
synthetic-accessto suppress warnings relative to unoptimized access from inner classes( 抑制子類沒有按最優方法訪問內部類的警告)
uncheckedto suppress warnings relative to unchecked operations( 抑制沒有進行類型檢查操作的警告)
unqualified-field-accessto suppress warnings relative to field access unqualified( 抑制沒有權限訪問的域的警告)
unusedto suppress warnings relative to unused code( 抑制沒被使用過的代碼的警告)

轉載于:https://www.cnblogs.com/weibanggang/p/11336700.html

總結

以上是生活随笔為你收集整理的@SuppressWarnings注解用法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。