public static void main(String[] args) {
// TODO Auto-generated method stub
KeyboardReader reader = new KeyboardReader ();
double money = 0; //Cash Variable
int Choice = 0; //Menu Choice
Scanner AccountIn = new Scanner(System.in); //Scanner for AccountNumbers
ArrayList<String> AccountNumber = new ArrayList<String>();
String accountValue = "";
int x = 1;
do{
try{
System.out.println("Create Account Number");
accountValue = AccountIn.nextLine();
if(accountValue.length()>0 && accountValue.length()<=9){
accountValue.add(AccountNumber); //Add UserInput to arrayList
System.out.println("Final Amount:" +money);
我正在尝试添加用户输入&#39; accountValue&#39;进入ArrayList&#39; AccountNumber&#39;但是当我选择查看它时它不显示。
答案 0 :(得分:2)
尝试替换它:
accountValue.add(AccountNumber);
使用:
AccountNumber.add(accountValue);
AccountNumber
是ArrayList,accountValue
是要存储的值。