我有一個問題,我無法獲取值進入我的數組列表中的某個位置。我有用戶輸入,成功地將字符串存儲到變量,但我不知道如何將它們放入數組的特定單元格。將字符串輸入ArrayList
代碼:
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);
}
請考慮放棄發佈的代碼中的'>',因爲它們會分散注意力並使代碼難以閱讀。謝謝。 –
您必須提及'account'變量的數據類型。 – Shivam
你能*請*按照教程? (也許一個在各種集合類型。)這必須是今天晚上第10次這個問題(或一個非常相似)已經出現.. – 2012-12-27 03:57:36