Java Class getDeclaredFields() MethodLast Updated : 17 Mar 2025 The 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 1Output: Field (1)long ClassgetDeclaredFieldsExample1.l Field (2)int ClassgetDeclaredFieldsExample1.i Field (3)java.lang.String ClassgetDeclaredFieldsExample1.p Example 2Output: 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 request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India