Javatpoint Logo
Javatpoint Logo

Java Class getDeclaredField() Method

The getDeclaredField() method of java Class class returns a field object representing the specified field declared inside the class or interface of this class.

Syntax

Parameter

name - the name of the field

Returns

Field object.

Throws

NoSuchMethodException , SecurityException

Example 1

Test it Now

Output:

Field = long ClassgetDeclaredFieldExample1.lng

Example 2

Test it Now

Output:

private int ClassgetDeclaredFieldExample2.intgr
public java.lang.String ClassgetDeclaredFieldExample2.str

Next TopicJava Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA