Java Class getDeclaredConstructors() MethodThe getDeclaredConstructors() method of java Class class returns an array of constructor objects representing all the constructors defined in this class object. If no constructor is declared, then it returns an array of length 0. SyntaxParameterNA ReturnsAn array of constructor object. ThrowsSecurityException Example 1Test it NowOutput: no argument constructor Constructor : 1 = private ClassgetDeclaredConstructorsExample1() Constructor : 2 = public ClassgetDeclaredConstructorsExample1(java.lang.Double,java.lang.Long) Example 2Test it NowOutput: private ClassgetDeclaredConstructorsExample2(java.lang.String) public ClassgetDeclaredConstructorsExample2(int) public ClassgetDeclaredConstructorsExample2()
Next TopicJava Class
|