有人可以指出我在这里正确的方向或填写我失踪的东西。真的很感激。感谢
我收到了这些错误:
E:\Data Netw Proj\BankingApp\BankingServant.java:26: error: cannot find symbol
ArrayList <Accounts> accounts = new ArrayList<Accounts>();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:26: error: cannot find symbol
ArrayList <Accounts> accounts = new ArrayList<Accounts>();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:37: error: cannot find symbol
Accounts lodge = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:37: error: cannot find symbol
Accounts lodge = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:47: error: cannot find symbol
Accounts trans = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:47: error: cannot find symbol
Accounts trans = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:58: error: cannot find symbol
Accounts with = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:58: error: cannot find symbol
Accounts with = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:67: error: cannot find symbol
Accounts bal = new Accounts();
^
symbol: class Accounts
location: class BankingServant
E:\Data Netw Proj\BankingApp\BankingServant.java:67: error: cannot find symbol
Accounts bal = new Accounts();
^
symbol: class Accounts
location: class BankingServant
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
10 errors
Tool completed with exit code 1
这是代码:
//package BankingApp;
//import BankingApp._BankingImplBase;
import BankingApp.*;
import java.util.ArrayList;
import java.util.Iterator;
public class BankingServant extends _BankingImplBase {
private String accName;
private int lodgementAmount ;
private int transAmount ;
private int transAccName ;
private int withAccName;
private int withAmount;
private int checkBal;
private class Account {
String accName;
int lodgementAmount;
int transAmount;
int withAmount;
int checkBal;
ArrayList <Account> accounts;
}
ArrayList <Accounts> accounts = new ArrayList<Accounts>();
{
ArrayList<Account> accounts = new ArrayList();
}
public boolean makeLodgement(String accName, int lodgementAmount) {
System.out.println("Lodgement");
Accounts lodge = new Accounts();
lodge.accName = accName;
lodge.lodgementAmount = lodgementAmount;
lodge.accounts = this.accounts;
accounts.add(lodge);
System.out.println("Money Lodged");
}
public boolean makeTransfer(String transAccName, int transAmount) {
System.out.println("transfer");
Accounts trans = new Accounts();
trans.transAccName = transAccName;
trans.transAmount = transAmount;
trans.accounts = this.accounts;
accounts.add(trans);
System.out.println("Money transfered");
}
public boolean makeWithdrawl(String withAccName, int withAmount) {
System.out.println("Withdrawl");
Accounts with = new Accounts();
with.withAccName = withAccName;
with.withAmount = withAmount;
with.accounts = this.accounts;
accounts.add(with);
System.out.println("Money Withdrawn");
}
public boolean checkBalance(String balAccName, int checkBal) {
System.out.println("Balance");
Accounts bal = new Accounts();
bal.transAccName = balAccName;
bal.checkBal = checkBal;
bal.accounts = this.accounts;
accounts.add(bal);
System.out.println("balance is: ");
}
}
答案 0 :(得分:3)
班级名称为Account
,您将其称为Accounts
。这是错误。
将数组列表声明为ArrayList<Account>
。