In Java8, through @Repeatable, the same class can be annotated multiple times.
1. Use annotation containers.
@Hints({@Hint("hint1"), @Hint("hint2")}) class Person {}
2. Use repeatable comments. The Java compiler can automatically set @Hint internally. This is important when reflexive reading of annotation information is required.
@Hint("hint1") @Hint("hint2") class Person {}
Collections in Java are mainly divided into four categories:
1. List list: ordered, can Repeated;
2. Queue queue: ordered, repeatable;
3. Set collection: non-repeatable;
4. Map mapping: unordered, key Unique, value is not unique.
The above is the detailed content of How to use @Repeatable in java. For more information, please follow other related articles on the PHP Chinese website!