public class Annotation1 {
@MyAnnotation(age=10,name="张三")
public void fun() {
}
@MyAnnotation(name="李四")
public void fun2() {
}
}
/**
* 定义注解(注解都是Annotation的子类)a
* 注解可以放在类、方法、构造函数、参数、局部变量、属性、包
* @author Administrator
*
*/
@interface MyAnnotation{
//定义注解属性。注解类型有八种:String 、Eum枚举、 int 、注解类型、类类型和这些之前的各一维数组
int age() default 100;//注解的属性默认值
String name();
}
@Retention(RetentionPolicy.RUNTIME)
@interface my1{
}