Java Class getDeclaredConstructor() MethodThe getDeclaredConstructoe() method of java Class class returns a constructor object representing all the constructors present in the class. SyntaxParameterparameterTypes - the parameter array ReturnsConstructor object. ThrowsNoSuchMethodException , SecurityException Example 1Test it NowOutput: 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 2Test it NowOutput: Default constructor Constructor = public ClassgetDeclaredConstructorExample2(java.lang.Double,java.lang.Long) Next TopicJava Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India