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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable