I have a dynamic ArrayList that I am using to populate a bank with
bank accounts. When I open a new account I add the account to the
ArrayList. Later I want to print what I have just done by showing the
account number and the initial deposit. The problem is I don't know
how to call the indexed account with an integer. The accounts are
added in this form at the end 0,1,2,3, etc. The only thing I could
think of was myArrayList.get - but what is the parameter of get if
the ArrayList is dynamic and automatically handles the numbering of
the index. Here is the method. If anyone knows what instance method
to place in the println statement please reply:
private void openNewAccount()
{
// prompt for initial deposit
int startup = atm.readInt( "Initial deposit: " );
// create newAccount
BankAccount newAccount = new BankAccount( startup, this );
// @@@DeMarco add it to accountList
accountList.add(newAccount);
// @@@DeMarco inform user without including account number
atm.println( "opened new account " + ??? place account number
here ??? + " with $" + newAccount.getBalance());
}