Javatpoint Logo
Javatpoint Logo

Java Class getDeclaredConstructor() Method

The getDeclaredConstructoe() method of java Class class returns a constructor object representing all the constructors present in the class.

Syntax

Parameter

parameterTypes - the parameter array

Returns

Constructor object.

Throws

NoSuchMethodException , SecurityException

Example 1

Test it Now

Output:

Constructor with no parameter :  public ClassgetDeclaredConstructorExample1()
Constructor with int as parameter type  :  public ClassgetDeclaredConstructorExample1(int)
Constructor with String as  parameter  type  :  private ClassgetDeclaredConstructorExample1(java.lang.String)

Example 2

Test it Now

Output:

Default constructor
Constructor  =  public ClassgetDeclaredConstructorExample2(java.lang.Double,java.lang.Long)

Next TopicJava Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA