Constructor getDeclaringClass() method in Java with Examples
The constructor class provides information about a single constructor for a class and it also provides access to that constructor.
The getDeclaringClass() method of java.lang.reflect.Constructor is used to return the class object representing the class that declares the constructor represented by this object. This method returns the name of the source class of this constructor.
public Class<T> getDeclaringClass()
Parameters: This method accepts nothing.
Return: This method returns an object representing the declaring class of the underlying member.
Below programs illustrate getDeclaringClass() method:
Source class name : java.lang.String
Class Name : java.util.ArrayList
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.