Combining multiple @SuppressWarnings annotations - Eclipse Indigo

前端 未结 2 522
感动是毒
感动是毒 2021-01-30 03:45

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

So for example:

相关标签:
2条回答
  • 2021-01-30 04:13

    If you take a look inside the annotation you will see this:

    public @interface SuppressWarnings {
        String[] value();
    }
    

    as you see, the value parameter is an array of Strings... so the parameter in the annotation can be: value1, value2 or value3 where

    final String[] value1 = { "a1" };
    final String[] value2 = { "a1", "a2" };
    final String[] value3 = { "a1", "a2", "a3" };
    

    i.e.:

    @SuppressWarnings({"unused"})
    @SuppressWarnings({"unused", "javadoc"})
    

    you can oft see something like

    @SuppressWarnings("unused") 
    

    and this is a particular case allowing one element wit no "{ }"

    0 讨论(0)
  • 2021-01-30 04:27

    Use the following: @SuppressWarnings({"unused", "unchecked"})

    0 讨论(0)
提交回复
热议问题