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.
//w w w .j ava 2s . 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.