java - Cannot get array to store input in next array slot -


i'm creating banking system , can't seem store name of customer names in array. last customer name overridden on next customer. these lines concerning array.

arraylist<string> allnames1 = new arraylist<string>();  system.out.println("please enter account holders name:");                      allnames1.add(sc.nextline());  system.out.println("account created. overview , balance: " + "\n" + allnames1); 

after happens user taken "main menu" in class.

allnames1.add ("a")

allnames1.add ("b") enough.

if doesn't work; think because allnames1 newly created every time.. or sc.nextline wrong.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -