zoukankan      html  css  js  c++  java
  • about @SuppressWarnings.

    about  @SuppressWarnings.

            项目组来了个很Picky的头,看到Eclipse里有大量的Warning小发了下脾气后,让用@SuppressWarnings这个标注来把Warning去掉.
           
            为了去掉由于泛型的Warning,我们用了@SuppressWarnings("unchecked"),为了去掉那些由于deprecation而引起的Warning,用了@SuppressWarnings("deprecation").但一个类中既有unchecked又有deprecation时,怎么办?于是用了一个很权宜之计:在类声明那用@SuppressWarnings("deprecation"),而在相应的方法声明里用@SuppressWarnings("unchecked").

           用了效果当然也达到了,可就想问在一个单独的@SuppressWarnings里既去掉deprecation又去掉unchecked呢?觉得应该可以达到的.于是就用下面的方式来试.
            1,@SuppressWarnings("deprecation","unchecked"),不行,Eclipse报错.
             2,@SuppressWarnings("deprecation,unchecked"),不行,还是报错.
             3,看@SuppressWarnings的源码,只有一个String[]类型的value.就想用@SuppressWarnings(new String[]{"deprecation","unchecked"}),还是不行,报错.
             4, Google了下后,发现了这个@SuppressWarnings(value={"deprecation"}),于是就想起来了@SuppressWarnings(value={"deprecation","unchecked"}).呵呵,成了.
           
            好久没用接触过标注了,快忘了. 现在记下来.


  • 相关阅读:
    HHHOJ #153. 「NOI模拟 #2」Kotomi
    HHHOJ #151. 「NOI模拟 #2」Nagisa
    Luogu P5298 [PKUWC2018]Minimax
    Luogu P5368 [PKUSC2018]真实排名
    Luogu P5408 【模板】第一类斯特林数·行
    Codechef December Challenge 2019 Division 1
    AtCoder Grand Contest 040
    CSP2019游记(翻车记)
    Codeforces Round #594 (Div. 1)
    AtCoder Grand Contest 039
  • 原文地址:https://www.cnblogs.com/fedorayang/p/5094214.html
Copyright © 2011-2022 走看看