public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
Returns true if an annotation for the specified type is present on this element, else false.
Examples
package com.logicbig.example.field;
import java.lang.reflect.Field;
public class IsAnnotationPresentExample3 { private static class Test { @Deprecated private String str; }
public static void main(String... args) throws NoSuchFieldException { Field f = Test.class.getDeclaredField("str"); boolean b = f.isAnnotationPresent(Deprecated.class); System.out.println(b); } }