定义简单的注解

定义一个注解

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserCase{
    public int id();
    public String description() default "no description"
}

@Target: 定义了注解可以应用用在哪里 (方法上,类上 等)

@Retention: 定义了注解在什么时候可用 (源码中 SOURCE, 类文件中 CLASS, 或运行时 RUNTIME

posted @ 2022-08-17 22:34  简单易懂  阅读(12)  评论(0编辑  收藏  举报