`

@suppresswarnings

    博客分类:
  • j2se
阅读更多

about @SuppressWarnings.

关键字: @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"}).呵呵,成了.
       
        好久没用接触过标注了,快忘了. 现在记下来

分享到:
评论

相关推荐

    @SuppressWarnings

    J2SE 提供的最后一个批注是 @SuppressWarnings。该批注的作用是给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默。 一点背景:J2SE 5.0 为 Java 语言增加了几个新的特性,并且和它们一起增加了...

    关于@SuppressWarnings("uncheck ")(转)

    关于@SuppressWarnings("uncheck ")

    Java分组、分页源码

    @SuppressWarnings("unused") private List pageList;// 存放分页中5页信息 @SuppressWarnings("unused") private boolean isFirstPage;// 是否为第一页 @SuppressWarnings("unused") private boolean ...

    @SuppressWarnings简介

    :java.lang.SuppressWarnings是J2SE 5.0中标准的Annotation之一。可以标注在类、字段、方法、参数、构造方法,以及局部变量上。

    jsp图书馆管理系统毕业设计

    @SuppressWarnings("unchecked") public List getBookcase(); public Bookcase getBookcaseById(Long id); public boolean validateByName(String name); public int allRowCount(); @...

    java写字板字体文件类源代码

    @SuppressWarnings("static-access") public FontFrame(MyNotepad myNotepad){ @SuppressWarnings("unused") int i = this.showConfirmDialog(myNotepad, createJPanel(), "字体", JOptionPane.OK_CANCEL_...

    ssh 万能类分页系统,可复用!

    @SuppressWarnings("unused") private boolean isFirstPage;//是否为第一页 @SuppressWarnings("unused") private boolean isLastPage;//是否为最后一页 @SuppressWarnings("unused") private boolean has...

    flume-plugin-maven-plugin-1.0.zip

    suppress-warnings.zip,@suppressWarnings注释的常量@suppressWarnings注释的常量

    java编写根据模板导出excel

    @SuppressWarnings({ "rawtypes", "unchecked" }) public void exportAndDownload(String templateFile, List<HashMap> datas) { try { filename = UUID.randomUUID() + templateFile; // FacesContext ...

    ibatis例子=》包含了常用方法介绍

    @SuppressWarnings("unchecked") public Map queryForMap(String sql_name, Object parameterObject, String keyProp,String valueProp) { Map map = null; try { map = sqlMap.queryForMap(sql_name, ...

    计算器java源码

    @SuppressWarnings("serial") public class testCalculator extends Frame { GridLayout g1; Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15; Panel p1,p2; Double x,y; JTextField tf1 = ...

    zxing.jar java生成二维码

    @SuppressWarnings("rawtypes") Map map = new HashMap(); //设置二维码的级别 map.put(EncodeHintType.ERROR_CORRECTION,ErrorCorrectionLevel.M); //设置二维码中文本的编码格式 map.put(EncodeHintType....

    hbase创建二级索引

    @SuppressWarnings("deprecation") @Override protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException { //获取所有需要建索引的列 Set[]> keys...

    观看韩顺平学习整理java的笔记到异常

    帮助大家复习java基础知识其中有 hashCode 2 ...@SuppressWarnings 注解 17 元注解 19 @Retention 注解 19 @Target 注解 19 @Documented注解 20 @Inherited 注解 20 异常-Exception 21 编译异常 22 异常处理 2

    java网络编程抓取指定网页信息--UrlHtml(java源码)

    @SuppressWarnings("deprecation") public static void main(String[] s) throws IOException{ try { URL url = new URL("http://www.kum.net.cn"); DataInputStream in = new DataInputStream(url.open...

    BluetoothDemoV1.2

    @SuppressWarnings("unused") private static final int REQUEST_ENABLE = 0x1; private static final int REQUEST_EX = 1; /* 请求能够被搜索 */ private static final int REQUEST_DISCOVERABLE = 0x2; ...

    java操作json全jar包

    @SuppressWarnings("unchecked") Iterator<Object> it = jsonArr.iterator(); while(it.hasNext()){ String ff = (String)it.next(); System.out.println("获取的是:"+ff); } } }

    俄罗斯方块

    @SuppressWarnings("serial") class ERS_Block extends Frame { public static boolean isPlay=false; public static int level=1,score=0; public static TextField scoreField,levelField; public static ...

    LinkedList的用法

    @SuppressWarnings("unchecked") public static void main(String[] args) { LinkedList<String> list = new LinkedList(); list.add("aaa"); list.add("bbb"); list.add("ccc"); /* * public ...

Global site tag (gtag.js) - Google Analytics