我已经成功创建了一个 2D Arraylist,但我仍然在将我的值存储到 Arraylist 中时遇到问题。我的错误消息如下,“找不到符号 - 方法 add(int,java.lang.String)。我知道这可能是一个简单的修复,但我在网上或教科书中的任何地方都找不到它。我也想知道如果有更简单的方法来创建二维数组列表。谢谢。
这里是我声明二维数组的地方:
ArrayList <ArrayList<String>> account = new ArrayList<ArrayList<String>>()
;
这是我的代码:
public void newAccount()
{
firstName = JOptionPane.showInputDialog("What's your first name?");
nLastName = JOptionPane.showInputDialog("What's your last name?");
nAddress = JOptionPane.showInputDialog("What's your current address?");
nCity= JOptionPane.showInputDialog("What's your current city?");
nState = JOptionPane.showInputDialog("What's your current State?");
nZipCode = JOptionPane.showInputDialog("What's your current Zip Code?");
account.add( accountNumber, firstName);
account.add( accountNumber, nLastName);
account.add( accountNumber, nAddress);
account.add( accountNumber, nCity);
account.add( accountNumber, nState);
account.add(accountNumber, nZipCode);