|
Thanks for the reply,
Basically the last paragraph explains the exact problem. A user will enter either a 1 or a 2 as an accountID and then I need to search the array (accountID 1 and accountID 2 was already added to the array with a different method) and return the first matching record.
This is what Ive tried
private AccountRepository() {
int accountValue = 100;
int accountID=1;
for(int i=0; i< MAX_ACCOUNTS; i++){
accounts[i] = new Account(accountID++, accountValue+=100);
}
}
private static Account[] accounts = new Account[MAX_ACCOUNTS];
public coldbeveragejava.Account getAcount(int accountID) {
System.out.println("Entering AccountRepository getAcount");
return accounts[accountID];
}//This does not work at runtime
and also this
private AccountRepository() {
int accountValue = 100;
int accountID=1;
for(int i=0; i< MAX_ACCOUNTS; i++){
accounts[i] = new Account(accountID++, accountValue+=100);
}
}
private static Account[] accounts = new Account[MAX_ACCOUNTS];
public coldbeveragejava.Account getAcount(int accountID) {
if (accountID == accounts);
return accounts[accountID];
}//This gives me a message stating incomparable types
|