Java Package .isAnnotationPresent ( Class <? extends Annotation > annotationClass)
Syntax
Package.isAnnotationPresent(Class <? extends Annotation > annotationClass) has the following syntax.
public boolean isAnnotationPresent(Class <? extends Annotation> annotationClass)
Example
In the following code shows how to use Package.isAnnotationPresent(Class <? extends Annotation > annotationClass) method.
public class Main {
/*w w w . j av a2 s.com*/
public static void main(String args[]) {
Package[] pack = Package.getPackages();
for (int i = 0; i < pack.length; i++) {
System.out.println(pack[i].isAnnotationPresent(Deprecated.class));
}
}
}
The code above generates the following result.