Java Reflection - Java Constructor .getDeclaringClass ()


Constructor.getDeclaringClass() has the following syntax.

public Class <T> getDeclaringClass()


In the following code shows how to use Constructor.getDeclaringClass() method.

import java.lang.reflect.Constructor;
// w ww .ja  va  2s  . c o m
public class Main {
  public static void main(String[] args) throws ClassNotFoundException {
    Class c = Class.forName("java.lang.String");

    Constructor[] constructors = c.getDeclaredConstructors();
    for (int i = 0; i < constructors.length; i++) {


The code above generates the following result.