how to get a user to add to an arraylist in java
public class chores {
public static void main(String[] args) {
Boolean close = false;
ArrayList<String> name = new ArrayList();
ArrayList<String> chores = new ArrayList();
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter '0'to exit");
System.out.println("Please enter name: ");
String answer = scanner.nextLine();
if (answer == "0") {
close = true;
System.out.println("Program has been terminated.");
}
else {
name.add(answer);
do {
System.out.println("Please enter chore: ");
answer = scanner.nextLine();
chores.add(answer);
System.out.println("Please enter name: ");
name.add(answer);
}while(answer != "0");
}
}
}
Also in Java:
- Java copy file
- java convert string to int array
- how to detect device javascirpt
- how to initialize an array in java
- creating a program about user asked to enter a number and enters 0 to stop, then calculates the sum of numbers entered, the average, the length of positive numbers and negative numbers entered by the user in java
- arraylist in java
- creating file in specific location in java application
- android how to know when snackbar is done
- set color of text for jlabel
- enhanced for loop java
- remove unused imports intellij
- mock ParameterizedTypeReference
- java how to initialize an array
- convert hashset to int array java
- parsedouble java
- how to open a text file in java
- how to minimize jframe in java
- bukkit java get player count
- jbutton close jframe java
- main method java
- java thread
- how to remove all special characters from a string in java
- java add a list to a list
- Please ensure that your JAVA_HOME points to a valid Java SDK. You are currently pointing to: /usr/lib/jvm/java-13-oracle