Class getDeclaredField() method in Java with Examples

The getDeclaredField() method of java.lang.Class class is used to get the specified field of this class. The method returns the specified field of this class in the form of Field object.

Syntax:

public Field getDeclaredField(String fieldName)
       throws NoSuchMethodException,
              SecurityException

Parameter: This method accepts a parameter fieldName which is the Field to get.

Return Value: This method returns the specified field of this class in the form of Field objects.

Exception This method throws: