0
我無法從我的客戶類中創建的Account ArrayList中打印結果。顯示子類中的Arraylist的內容
public static void customerInteraction(Customer cust) throws Exception {
Scanner read = new Scanner(System.in);
int custInput;
//write the logic here to interact with the customer and the account(s)
System.out.println("Your customer was successfully located.");
System.out.println("Hi "+cust.fullName());
System.out.println("Here are your Accounts.");
// display the Accounts in the list
**for (int i = 0; i < cust.acctList.size(); i++) {
System.out.printf(" %s", cust.acctList.get(i));**
**}**
我可以創建一個客戶和賬戶信息保存到acctlist帳戶的ArrayList
Customer Class
public void addAccount(String acctType) {
if (acctType.equalsIgnoreCase("CHECKING")) {acctList.add(new Checking(this.custId));
} else {
acctList.add(new Savings(this.custId));
}
}
你得到了什麼錯誤? – Mureinik
'acctList'是公開的嗎? –
ArrayList acctList = new ArrayList <>();在客戶類別中聲明 –
SvenJG