package cn.itcast.day2;
import java.lang.reflect.Method;
import javax.jws.soap.InitParam;
public static void main(String[] args) throws Exception{
System.runFinalizersOnExit(true);
if(AnnotationTest.class.isAnnotationPresent(ItcastAnnotation.class)){
ItcastAnnotation annotation = (ItcastAnnotation)AnnotationTest.class.getAnnotation(ItcastAnnotation.class);
//这里和下面的强转有什么不同呢?
System.out.println(annotation.color());
System.out.println(annotation.value());
System.out.println(annotation.arrayAttr().length);
System.out.println(annotation.lamp().nextLamp().name());//这里究竟是怎么调用的?
System.out.println(annotation.annotationAttr().value());
}
Method mainMethod = AnnotationTest.class.getMethod("main", String[].class);
ItcastAnnotation annotation2 = (ItcastAnnotation)mainMethod.getAnnotation(ItcastAnnotation.class);
//这里强转是什么意思呢?
System.out.println(annotation2.value());
}
}
实在是看不懂啊,求指导思路。
|
|