In this tutorial we are going to learn how to get constructor and it’s parameter of a class . See the below example .

package com.java;
import java.lang.reflect.Constructor;

class Sample 
{
    Sample(){
    }
    Sample(int a , String name){
    }
    public static void main(String[] args) throws Exception
    {
        Class c1=Class.forName("com.java.Sample");
        Sample gcd=new Sample();
        Constructor con[]=c1.getDeclaredConstructors();
        for(Constructor cn:con)
        {
            System.out.println("constructor name is : "+cn.getName());
            System.out.println("arguments types are : ");
            Class c2[]=cn.getParameterTypes();
            for(Class c3:c2)
            {
                System.out.println(c3.getName());
            }
        }
    }
}

/* 

Output :

constructor name is : com.java.Sample
arguments types are : 
constructor name is : com.java.Sample
arguments types are : 
int
java.lang.String

*/

If we want to get public constructor details only then we have to use getConstructors() method . It will all give all public Constructor details from super classes also .