Home > Java > javaTutorial > How to use annotations in java8

How to use annotations in java8

WBOY
Release: 2023-05-01 11:58:06
forward
1760 people have browsed it

1. Define packaging comments, including an array of actual comments.

@interface Hints {
    Hint[] value();
}
 
@Repeatable(Hints.class)
@interface Hint {
    String value();
}
Copy after login

2. Annotation container.

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

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

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!

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