package com.liming.study;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(value = {ElementType.METHOD,ElementType.TYPE})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
String value() default "";
int id() default 0;
String[] list() default {"胖虎"};
}
package com.liming.study;
import java.util.ArrayList;
import java.util.List;
public class AnnotationTest {
public static void main(String[] args){
System.err.println("Hello Annotation");
test();
}
@MyAnnotation(value="Hello",id=123,list = {"大雄","小夫"})
private static void test(){
System.err.println("Test");
}
@Override
public String toString() {
return super.toString();
}
}