How to set String Array in Java Annotation

后端 未结 1 1970
情书的邮戳
情书的邮戳 2020-12-05 12:52

I have declared a annotation like this:

public @interface CustomAnnot 
{
    String[] author() default \"me\";
    String description() default \"\";
}


        
相关标签:
1条回答
  • 2020-12-05 13:02

    Do it like this:

    public @interface CustomAnnot {
    
        String[] author() default "me";
        String description() default "";
    
    }
    

    And your annotation:

        @CustomAnnot(author={"author1","author2"}, description="test")
    
    0 讨论(0)
提交回复
热议问题