注解
package sys.test;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Foo {
String[] value();
boolean bar();
}
package sys.test;
import java.util.Arrays;
@Foo(value = {"aaa", "vvv"}, bar = true)
public class Demo {
public static void main(String[] args) {
Foo annotation = Demo.class.getAnnotation(Foo.class);
System.out.println(Arrays.toString(annotation.value()));
System.out.println(annotation.bar());
}
}