Get the annotations

ReturnMethodSummary
<A extends Annotation>A getAnnotation(Class<A> annotationClass) Returns this element's annotation for the specified type if such an annotation is present, else null.
Annotation[]getAnnotations()Returns all annotations.
Annotation[]getDeclaredAnnotations()Returns all annotations that are directly present on this element.

public class Main {
  public static void main(String[] args) {
    Package[] ps = Package.getPackages();
    
    for(Package p:ps){
      System.out.println(p.getAnnotations().length);
    }

  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.