⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 annotationreader.java

📁 一步 教你学会java 完成一个完整的SWT系统 是本人学习java时按教程一步一步写下来的咯
💻 JAVA
字号:
import java.lang.annotation.*;import java.lang.reflect.*;/** *  Read annotation information from a class at runtime using the new  *  JDK1.5 reflection features **/public class AnnotationReader {  AnnotatedClass ac;  /**   *  Constructor   **/  public AnnotationReader() {    ac = new AnnotatedClass();  }  /**   *  Print out runtime annotation information   **/  public void printAnnotations() {    Class c = ac.getClass();	Annotation[] annotations = c.getAnnotations();    int numberOfAnnotations = annotations.length;    System.out.println("Class " + c.getName() + " has " +      numberOfAnnotations + " annotations");    for (int i = 0 ; i < numberOfAnnotations; i++) {      System.out.println("Annotation " + i + ": " + annotations[i] +        ", type" + annotations[i].annotationType().getName());    }      }  /**   *  Main entry point   *   * @param args Command line arguments   **/  public static void main(String[] args) {    AnnotationReader ar = new AnnotationReader();    ar.printAnnotations();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -