package com.kuang.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@SuppressWarnings("all")
public class TestDIYAnnotation03 {
@MyAnnotation2(age=18,name = "秦疆")
public void test(){}
@MyAnnotation3("qingjiang")
public void test1(){}
}
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation2{
//注解的参数: 参数类型+参数名();
String name() default "";
int age();
int id() default -1;//如果默认值为-1,代表不存在
String[] schools() default {"西部开源","清华大学"};
}
@Target({ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation3{
//注解的参数: 参数类型+参数名();
String value() ;
}