Java Data Type Tutorial - Java Package.getAnnotation(Class <A> annotationClass)








Syntax

Package.getAnnotation(Class <A> annotationClass) has the following syntax.

public <A extends Annotation> A getAnnotation(Class <A> annotationClass)

Example

In the following code shows how to use Package.getAnnotation(Class <A> annotationClass) method.

/*www. ja v  a 2  s .  co m*/


public class Main {
   public static void main(String args[]) {

     // create a package object for java.lang package
     Package pack = Package.getPackage("java.io");

     System.out.println(pack.getAnnotation(Deprecated.class));
     
   }
}

The code above generates the following result.