Why does the second Test in my scenario has the syntax error The value for annotation attribute SuppressWarnings.value must be an array initializer on the SuppressWarnings line?
public class AnnotationTest {
private static final String supUnused = "unused";
private static final String supDeprecation = "deprecation";
private static final String[] suppressArray = { "unused", "deprecation" };
public static void main(String[] args) {
// Test 1
@SuppressWarnings( { supUnused, supDeprecation } )
int a = new Date().getDay();
// Test 2
@SuppressWarnings(suppressArray) // syntax error
int b = new Date().getDay();
}
}
If you're passing the parameters as two single constants, it works.
If you're passing it with an array constant, there is a syntax error.
What is the explanation for this error?
SupressWarnings;)