Online Java Compiler By
JavaTpoint.com
import java.lang.reflect.Constructor; public class ClassgetDeclaredConstructorExample1 { public ClassgetDeclaredConstructorExample1() { } public ClassgetDeclaredConstructorExample1(int i) { } private ClassgetDeclaredConstructorExample1(String str) { } public static void main(String... args) throws NoSuchMethodException { Class
cls = ClassgetDeclaredConstructorExample1.class; Constructor
constrct = cls.getDeclaredConstructor(); System.out.println("Constructor with no parameter : " +constrct); constrct = cls.getDeclaredConstructor(int.class); System.out.println("Constructor with int as parameter type : " +constrct); constrct = cls.getDeclaredConstructor(String.class); System.out.println("Constructor with String as parameter type : " +constrct); } }
Output