Home  >  Article  >  Java  >  How to use @Repeatable in java

How to use @Repeatable in java

WBOY
WBOYforward
2023-05-03 13:37:061121browse

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 {}

What collection classes are there in Java?

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete