Home > Java > javaTutorial > body text

Instructions for using @Inherited annotation in Java

PHPz
Release: 2023-04-20 16:49:08
forward
1682 people have browsed it

Explanation

1. The tag indicates that the type of a certain tag is inherited. The annotation type modified by @inherited is used for class, and the annotation is used for subclasses of class. @inheritedannotation The type is a subclass of the marked class.

Function

2. Allow subclasses to inherit parent class annotations.

Instance

The annotation mark used by MyParentClass is @Inherited, and subclasses can inherit annotation information.

java.lang.annotation.Inherited
@Inherited
public @interface MyCustomAnnotation {
}
 
@MyCustomAnnotation
public class MyParentClass {
  ...
}
 
public class MyChildClass extends MyParentClass {
   ...
}
Copy after login

What collection classes are there in Java?

Collections in Java are mainly divided into four categories:

1. List: ordered, repeatable;

2. Queue: ordered and repeatable;

3. Set: non-repeatable;

4. Map: unordered, with unique keys and non-unique values.

The above is the detailed content of Instructions for using @Inherited annotation 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