Java Class getAnnotations() Method

The getAnnotations() method of java Class class returns annotations that are present on this element. If there are no annotations present on this element, then it returns an array of length 0. The caller of this method can modify the returned array.

Syntax

Parameter

No parameter is passed.

Returns

annotations present on this element

Throws

Does not throw an exception.

Example 1

Test it Now

Output:

Annotations not set

Example 2

Test it Now

Output:

@Class.Demo3(str=Demo Annotation, val=100)

Next TopicJava Class




Latest Courses