Javatpoint Logo
Javatpoint Logo

Java Method getAnnotation() Method

The getAnnotation() method of Method class returns this element's annotation if such an annotation is present for the specified type, otherwise returns null.

Syntax

Parameter

annotationClass - the Class object corresponding to the annotation type

Returns

This element's annotation if present on this element, otherwise null.

Throws

NullPointerException

Example 1

Test it Now

Output:

Demo_Annotation 100

Example 2

Test it Now

Output:

name_: getSplField
value_: Sample Method Annotation
Next TopicJava Method Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA