Java Class getDeclaredFields() MethodThe getDeclaredFields() method of java Class class returns an array of field objects representing all the fields defined in this class object. If no filed is declared, then it returns an array of length 0. SyntaxParameterNA ReturnsAn array of field object. ThrowsSecurity Exception Example 1Test it NowOutput: Field (1)long ClassgetDeclaredFieldsExample1.l Field (2)int ClassgetDeclaredFieldsExample1.i Field (3)java.lang.String ClassgetDeclaredFieldsExample1.p Example 2Test it NowOutput: Field (1)long ClassgetDeclaredFieldsExample2.l Field (2)int ClassgetDeclaredFieldsExample2.i Field (3)java.lang.String ClassgetDeclaredFieldsExample2.p Field (4)float ClassgetDeclaredFieldsExample2.f Field (5)boolean ClassgetDeclaredFieldsExample2.b 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