gpt4 book ai didi

java - 为什么我在这里收到错误?

转载 作者:行者123 更新时间:2023-12-02 00:06:25 26 4
gpt4 key购买 nike

有人可以在这里为我指出正确的方向或填写我缺少的内容吗?真的很感激。谢谢

我收到这些错误:

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: ");
}

}

最佳答案

类名是Account您将其称为 Accounts 。这就是错误。

将数组列表声明为ArrayList<Account> .

关于java - 为什么我在这里收到错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13767437/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com