Java Class getConstructor() Method

The getConstructor() method of java Class class returns a Constructor object that reflects the public constructor of the class.

Syntax

Parameter

parameterTypes - the parameter array.

Returns

Constructor object.

Throws

NoSuchMethodException , SecurityException

Example 1

Test it Now

Output:

public java.lang.String(java.lang.String)   //class path

Example 2

Test it Now

Output:

Default Constructor... 
Parameterized Constructor....(one parameter) 
public ClassgetConstructorExample2$Class1()
public ClassgetConstructorExample2$Class1(int)
public ClassgetConstructorExample2$Class1(java.lang.String,java.math.BigInteger[])

Next TopicJava Class




Latest Courses