Java Class getDeclaredAnnotations() MethodThe getDeclaredAnnotations() method of java Class class returns annotations that are directly present on this element and ignore inherited annotations. If no annotation is set, then it returns 0. SyntaxParameterNA ReturnsAll the annotations present on this element. ThrowsNA Example 1Test it NowOutput: key: getFieldvalue value: getting field attribute Example 2Test it NowOutput: @Demointerface(str=Demo Annotation, val=100) Java Class getDeclaredAnnotations() MethodThe getDeclaredClasses() method of java Class class returns an array of the class object representing all the classes and interface declared in this class object. If no annotations are declared, then it returns an array of length 0. SyntaxParameterNA ReturnsAn array of class object. ThrowsNo exception is thrown. Example 1Test it NowOutput: Class 1 = ClassgetDeclaredclassesExample1$InPrvtClass Class 2 = ClassgetDeclaredclassesExample1$InClass2 Class 3 = ClassgetDeclaredclassesExample1$InClass1 Example 2Test it NowOutput: Class 1 = AnotherClass$InnerPrivateClass Class 2 = AnotherClass$InrClass2 Class 3 = AnotherClass$InrClass1 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