Java Class getDeclaredAnnotationsByType() MethodThe getDeclaredAnnotationsByType() method of java Class class returns this element's annotation for the specified type if such an annotation is directly present, otherwise null. It ignores inherited annotations. SyntaxParameterannotationClass - the Class object corresponding to the annotation type ReturnsAnnotations ThrowsNullPointerException Example 1Test it NowOutput: [@java.lang.Deprecated()] [@ClassgetDeclaredAnnotationbytypeExample1$Annotation1()] Example 2Test it NowOutput: [@java.lang.Deprecated()] [@ClassgetDeclaredAnnotationbytypeExample2$Annotation1()] ClassgetDeclaredAnnotationbytypeExample2.subClass1
Next TopicJava Class
|