Java Class isAnnotationPresent() Method

The isAnnotationPresent() method of java Class class returns true if an annotation for the specified type is present on this element, false otherwise.

Syntax

Parameter

annotationClass - the Class object corresponding to the annotation type

Returns

true if an annotation for the specified annotation type is present on this element.

Throws

NullPointerException

Example 1

Test it Now

Output:

Check isAnnotationPresent  :::   false

Example 2

Test it Now

Output:

Check isAnnotationPresent  :::   true

Next TopicJava Class




Latest Courses