Java Class getField() MethodThe getField() method of java Class class returns a field object which represents the public member field of the class or interface represented by this Class object. A string specifying the simple name of the desired field is passed as the parameter. SyntaxParametername - the field name ReturnsField object. ThrowsNoSuchFieldException , NullPointerException , SecurityException Example 1Test it NowOutput: Field got = field found: public java.lang.String ClassgetFieldExample1.str Example 2Test it NowOutput: public int ClassgetFieldExample2.num int 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