1. Define packaging comments, including an array of actual comments.
@interface Hints { Hint[] value(); } @Repeatable(Hints.class) @interface Hint { String value(); }
2. Annotation container.
@Hints({@Hint("hint1"), @Hint("hint2")}) class Person {}
3. Repeatable annotations. The java compiler can automatically set @Hint internally. This is important for reading annotation information via reflection.
@Hint("hint1") @Hint("hint2") class Person {}
The above is the detailed content of How to use annotations in java8. For more information, please follow other related articles on the PHP Chinese website!