I am making a program where the person inputs multiple values and the Arraylist stores it as a single string with option 1. Option two allows you to change a specific part of that string from "Complete" to "Incomplete" and vice-versa but only if the status part of the String is one of the two. I am getting the warning "Result of 'String.replace()' is ignored" and the part of the string isn't updating. Any help would be appreciated!
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Array listObj = new Array();
Scanner userinput = new Scanner(System.in);
int arraysize = (listObj.list.size());
int power = 1;
while (power < 2) {
System.out.println("To-Do List / What would you like to do?");
System.out.println("1 = Add Task / 2 = Mark Task as Done / 3 = Remove Task / 4 = Edit Task / 5 = Display Tasks / 6 = Exit");
int selection = userinput.nextInt();
if (selection == 1) {
for (int i = 0; i <= arraysize; i++) {
String title;
String date;
String status;
String description;
String id;
System.out.print("Enter Title: ");
title = userinput.next();
System.out.print("Enter Due Date: ");
date = userinput.next();
System.out.print("Enter Status (Complete or Incomplete): ");
status = userinput.next();
System.out.print("Enter Description: ");
description = userinput.next();
listObj.list.add(title + " " + date + " " + status + " " + description);
System.out.println();
listObj.list.forEach(System.out::println);
System.out.println();
}
}
if (selection == 2) {
int idinput;
System.out.println("Enter Project ID to Toggle Complete/Incomplete: ");
idinput = (userinput.nextInt()-1);
System.out.println();
System.out.println(listObj.list.get(idinput));
System.out.println();
System.out.println("What is the status of this assignment?: ");
String toggleselect = userinput.next();
if (toggleselect.equals("Incomplete")) {
listObj.list.get(idinput).replace("Incomplete", "Complete");
} else if (toggleselect.equals("Complete")) {
listObj.list.get(idinput).replace("Complete", "Incomplete");
} else {
System.out.println("Status is not Complete/Incomplete");
}
System.out.println();
listObj.list.forEach(System.out::println);
System.out.println();
}
}
}
}
import java.util.ArrayList;
public class Array {
ArrayList<String> list = new ArrayList<String>();
public ArrayList<String> getList() {
return list;
}
}`your text`
your text"