how to get a user to add to an arraylist in java

Solutions on MaxInterview for how to get a user to add to an arraylist in java by the best coders in the world

showing results for - "how to get a user to add to an arraylist in java"
Yuna
04 Nov 2016
1public class chores {
2
3	public static void main(String[] args) {
4		
5		Boolean close = false;
6		
7		ArrayList<String> name = new ArrayList();
8		ArrayList<String> chores = new ArrayList();
9		
10		Scanner scanner = new Scanner(System.in);
11		
12		System.out.println("Please enter '0'to exit");
13		System.out.println("Please enter name: ");
14		String answer = scanner.nextLine();
15		if (answer == "0") {
16			close = true;
17			System.out.println("Program has been terminated.");
18		}
19		else {
20			name.add(answer);
21			
22			do {
23				
24				System.out.println("Please enter chore: ");
25				answer = scanner.nextLine();
26				chores.add(answer);
27				System.out.println("Please enter name: ");
28				name.add(answer);
29				
30				
31			}while(answer != "0");
32        }
33    }
34}