A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 一碗小米周 中级黑马   /  2013-12-15 19:29  /  973 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 一碗小米周 于 2013-12-17 18:46 编辑

我谢了一个注解类,并应用到了另一个类中了。本来是可以输出结果的。怎么突然不能输出结果了呢?求帮忙看下。谢谢各位。
  1. import java.lang.annotation.*;
  2.         @Retention(RetentionPolicy.RUNTIME)// 编译器将把注释记录在类文件中,在运行时 VM 将保留注释
  3.         @Target(ElementType.METHOD)//指定注解类存放位置,存放在类中,方法上等等。
  4.         public @interface MyAnnotation
  5.         {
  6.                
  7.         }
复制代码
  1. import java.lang.annotation.Annotation;

  2. public class AnnotationTest {
  3.         @MyAnnotation        
  4.         public static void main(String[] args) {
  5.                 if (AnnotationTest.class.isAnnotationPresent(MyAnnotation.class)) {
  6.                         Annotation annotation = AnnotationTest.class.getAnnotation(MyAnnotation.class);
  7.                         System.out.println(annotation);
  8.                 }
  9.                 }
  10.         }
复制代码



评分

参与人数 1技术分 +1 收起 理由
乔兵 + 1

查看全部评分

1 个回复

倒序浏览
LZ解决了没,我也没结果
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马