Java Class getDeclaredConstructors() 方法

2025年3月21日 | 阅读 1 分钟

Java Class 类的 getDeclaredConstructors() 方法返回一个构造函数对象数组,该数组表示此类对象中定义的所有构造函数。如果未声明任何构造函数,则返回长度为 0 的数组。

语法

参数

不适用

返回值

构造函数对象数组。

抛出

SecurityException

示例 1

输出

no argument constructor
Constructor  : 1 =  private ClassgetDeclaredConstructorsExample1()
Constructor  : 2 =  public ClassgetDeclaredConstructorsExample1(java.lang.Double,java.lang.Long)

示例 2

输出

private ClassgetDeclaredConstructorsExample2(java.lang.String)
public ClassgetDeclaredConstructorsExample2(int)
public ClassgetDeclaredConstructorsExample2()
 
下一个主题Java类