所以我必須爲學校設計一個簡單的銀行業務程序,並且我無法檢查我的陣列是否有特定的帳號。(首次編程)如何檢查某個特定值的類的數組?
基本信息,而不是全碼:
public class Account {
public String name;
int number;
double Balance;
private Account [] accounts;
public Account[] getAccounts() {
return accounts;
}
public boolean hasAccountNumber(int accountNumber) {
// How do I check my array of type Account if it has the passed in account number?
// I was trying to use the following:
Account[] b = getAccounts();
if(Arrays.asList(b).contains(accountNumber)){
return true;
} else{
return false;
}
}
}
爲什麼不是這方面的工作?
爲什麼要轉換爲列表?爲什麼不使用列表?任何你不使用列表的原因? – Tirath 2014-10-03 18:59:48
什麼是錯誤,或堆棧跟蹤顯示? – Rika 2014-10-03 19:00:35
如何比較'整個帳戶'對象? – Seitaridis 2014-10-03 19:12:52