@Retention(RetentionPolicy.RUNTIME)
public @interface ItcastAnnocation {
}
这个是我写的注解,我要用在另外一个类里面,下面的就是
public class AnnotationTest {
@SuppressWarnings("deprecation")
public static void main(String[] args) {
// TODO Auto-generated method stub
System.runFinalizersOnExit(true);
if(AnnotationTest.class.isAnnotationPresent(ItcastAnnocation.class)) {
ItcastAnnocation itcastAnnocation = AnnotationTest.class.getAnnotation(ItcastAnnocation.class);
System.out.println(itcastAnnocation);
}
else {
System.out.println("你得到的注解类有问题,首先查看是否是你注解类的生命周期的问题");
}
}
}
为何山么都没有打印出来,求解释?
|
|