import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Retention(RUNTIME)
@Target(ElementType.TYPE)
public @interface Anno {//自定义注解
String value() default "";
}
@Anno("/hello")
public class Test1{
.........
}
如果 Test1.isAnnotationPresent(Anno.class);意思就是:判断Test1类上是否含有Anno注解。如果在则返回true;不在则返回false。