本帖最后由 张学林 于 2013-3-20 10:01 编辑
大家帮我看看啊,这是什么原因- package cn.itcast.day2;
- public class AnnotationTest {
- /**
- * @param args
- */
- @ItcastAnnotation
- public static void main(String[] args) {
- System.runFinalizersOnExit(true);
- System.out.println(AnnotationTest.class.isAnnotationPresent(ItcastAnnotation.class));//为啥后面加了@Retention(RetentionPolicy.RUNTIME)却还是false很是肺解
- if(AnnotationTest.class.isAnnotationPresent(ItcastAnnotation.class)){
- ItcastAnnotation annotation = (ItcastAnnotation)AnnotationTest.class.getAnnotation(ItcastAnnotation.class);
- System.out.println(annotation);
- }
- }
-
- @Deprecated
- public static void sayHello(){
-
- System.out.println("hi,你好");
- }
- }
复制代码 下面是类注解的- package cn.itcast.day2;
- import java.lang.annotation.Retention;
- import java.lang.annotation.RetentionPolicy;
- @Retention(RetentionPolicy.RUNTIME)
- public @interface ItcastAnnotation {
- }
复制代码 |