JAN*_*JAN 1 java reflection constructor
鉴于班级奖励:
public class Award {
/*
*
*/
// fields of the class
Award()
{
// some initializations
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试从Main调用此构造函数:
try
{
Award myAward = Award.class.getConstructor().newInstance();
myAward.calculateAward();
}
catch (Exception e)
{
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但它进入异常块并产生NoSuchMethodException异常.
怎么了 ?
谢谢 !
| 归档时间: |
|
| 查看次数: |
548 次 |
| 最近记录: |