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

标签 java

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

我收到这些错误:

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/

相关文章:

java - java中的系统覆盖Keylistener

java - 使用多个 Twitter4j 帐户发送多条推文(提及)

java - 重载 C++ 赋值运算符使其表现得像 Java

java虚拟机: type information

java - 我将 Eclipse 更新为 Photon,请问这是一个错误吗?

java - JEdi​​torPane 获取字符在行号和列号处的位置

java - 在 POM 中使用 --enable-preview 执行 Maven 插件

java - 一组整数作为输入来打印其立方之和

java - ClassNotFoundException : org. jboss.resteasy.client.jaxrs.ResteasyClientBuilder 错误

java - App Crashing with android material Chip Group with material 1.3.0