注解的英文单词 Annotation
3.有一个public修饰的“入口”
4.且该public修饰的类名必须与文件名相同
5.并且一个源文件可以只有非public类
package com.kuang.Annotation;
//测试元注解
import java.lang.annotation.*;
@MyAnnotation
public class Test02 {
@MyAnnotation
public void test(){
}
}
//定义一个注解
//Target 表示我们的注释可以用在哪些地方
@Target(value = {ElementType.METHOD,ElementType.TYPE})
//Retention 表示我们的注解在什么时候有效
//runtime>class>sources
@Retention(value = RetentionPolicy.RUNTIME)
//表示是否将我们的注解生成在Javadoc中
@Documented
//子类可以继承父类的注解
@Inherited
@interface MyAnnotation{
}