组合多个@SuppressWarnings 注释 - Eclipse Indigo [英] Combining multiple @SuppressWarnings annotations - Eclipse Indigo

查看:38
本文介绍了组合多个@SuppressWarnings 注释 - Eclipse Indigo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以问题是能够组合多个警告抑制,以便每个项目不需要它自己的 @SuppressWarnings 注释.

So the issue is being able to combine multple warning suppressions so that each item doesn't need it's own @SuppressWarnings annotation.

例如:

public class Example
    public Example() {
        GO go = new GO();  // unused
        ....
        List<String> list = ( List<String> ) go.getList(); // unchecked
    }
    ...
    // getters/setters/other methods
}

现在不是有两个 @SuppressWarnings 我想在类级别为这两个警告设置一个,就像这样:

Now instead of having two @SuppressWarnings I want to have one at the class level for those two warnings, so like this:

@SuppressWarnings( "unused", "unchecked" )
public class Example
    public Example() {
        GO go = new GO();  // unused - suppressed
        ....
        List<String> list = ( List<String> ) go.getList(); // unchecked - suppressed
    }
    ...
    // getters/setters/other methods
}

但这不是有效的语法,有没有办法做到这一点?

But that is not a valid syntax, is there a way to do this?

推荐答案

使用以下内容:@SuppressWarnings({"unused", "unchecked"})

这篇关于组合多个@SuppressWarnings 注释 - Eclipse Indigo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆