java.lang.ClassNotFoundException: SavingAccount
执行以下代码时出现异常,
public class AccountFactory {
public void getAccount()
{
IAccount account;
account = null;
try
{
account = (IAccount)Class.forName("SavingAccount").newInstance();
account.Deposit(500);
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
导致错误的可能原因是什么?
这是我的储蓄账户代码:
public class SavingAccount implements IAccount {
int money;
SavingAccount()
{
money =0;
}
public void WithDraw(int m)
{
money--;
}
public void Deposit(int m)
{
money++;
System.out.println(money);
}
}