Java Constructor .getDeclaringClass ()

Syntax

Constructor.getDeclaringClass() has the following syntax.

public Class <T> getDeclaringClass()

Example

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


import java.lang.reflect.Constructor;
/*from  ww w . jav a 2  s.  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++) {
      System.out.println(constructors[i].getDeclaringClass());
    }

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable