我想知道是否可以将对象存储到用户想要的数组列表中。对于我的程序,它通过“帐号”将用户数据存储到他们选择的单元格中,但是每次我输入新帐号时,它都会说数组基本上不够大。这是我的代码。如果有人可以提供帮助,将不胜感激。
ArrayList <Account> account = new ArrayList<Account>();
int accountNumber;
String nCity;
String nState;
String nZipCode;
String nLastName;
String nAddress;
String firstName;
String nAccount;
public void newAccount()
{
Account a = new Account();
a.firstName = JOptionPane.showInputDialog("What's your first name?");
a.nLastName = JOptionPane.showInputDialog("What's your last name?");
a.nAddress = JOptionPane.showInputDialog("What's your current address?");
a.nCity= JOptionPane.showInputDialog("What's your current city?");
a.nState = JOptionPane.showInputDialog("What's your current State?");
a.nZipCode = JOptionPane.showInputDialog("What's your current Zip Code?");
String num = JOptionPane.showInputDialog("What do you want your account number to be?");
accountNumber = Integer.parseInt(num);
account.add(accountNumber, a);