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 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India