Wednesday 25 June 2014

Defaults for Annotation Type Elements

An annotation type element may have a default value. Using default keyword you can specify a default value for the annotation element.

public @interface AuthorDetails{
 String author();
 String date();
 int currentVersion() default 1;
 String lastModified() default "N/A";
 String[] Reviewers();
}

1. Default values are not compiled into annotations, but rather applied dynamically at the time annotations are read. Thus, changing a default value affects annotations even in classes that were compiled before the change was made.




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment