Package.getAnnotation(Class <A> annotationClass) has the following syntax.
public <A extends Annotation> A getAnnotation(Class <A> annotationClass)
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.