Java Data Type Tutorial - 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 {
  
   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.