@ItcastAnnotation(color = "Green", value = "abc",arr = 3) //给这儿复制一个就可以了
public class AnnotationTest {
//@ItcastAnnotation(color = "Green", value = "abc",arr = 3)
public static void main(String[] args) {
// TODO Auto-generated method stub
if (AnnotationTest.class.isAnnotationPresent(ItcastAnnotation.class)) {
ItcastAnnotation itcastAnnotation = (ItcastAnnotation) AnnotationTest.class
.getAnnotation(ItcastAnnotation.class);
System.out.println(itcastAnnotation);
System.out.println(itcastAnnotation.color());
System.out.println(itcastAnnotation.value());
System.out.println(itcastAnnotation.arr().length);
}
}
@Target({ElementType.METHOD,ElementType.TYPE})表示类名前 和方法前都可以加注解; |