package com.logicbig.example.method;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
public class GetDefaultValueExample {
public static void main(String... args) throws NoSuchMethodException {
Method m = DisplayInfo.class.getDeclaredMethod("index");
Object defaultValue = m.getDefaultValue();
System.out.println(defaultValue);
Method m2 = DisplayInfo.class.getDeclaredMethod("name");
Object defaultValue2 = m2.getDefaultValue();
System.out.println(defaultValue2);
}
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
private @interface DisplayInfo {
int index() default 5;
String name();
}
}