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

How to use @Repeatable in java

WBOY
Release: 2023-05-03 13:37:06
forward
1221 people have browsed it

In Java8, through @Repeatable, the same class can be annotated multiple times.

1. Use annotation containers.

@Hints({@Hint("hint1"), @Hint("hint2")})
class Person {}
Copy after login

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 {}
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template