How to set String Array in Java Annotation
annotations, java
Solution
Do it like this:
public @interface CustomAnnot {
String[] author() default "me";
String description() default "";
}
And your annotation:
@CustomAnnot(author={"author1","author2"}, description="test")
Problem
I have declared a annotation like this: ``` public @interface CustomAnnot { String[] author() default "me"; String description() default ""; } ``` A valid Annotation therefore would be ``` @CustomAnnot(author="author1", description="test") ``` What I can't figure out is, how to set more than one author, since author() has return String[] this should be possible. ``` @CustomAnnot(author="author1","autor2", description="test") ``` doesn't work!