I'm having trouble deleting a collection of elements from an Arraylist. .remove() does not work for this situation.
I have the following arrayList called uncategorizedList that contains some information that I added with the following collection of elements.
List<ExpenseList> uncategorizedList = new ArrayList<>();
uncategorizedList.add(new ExpenseList("11/30/2017", "check deposit", 230.32));
uncategorizedList.add(new ExpenseList("09/12/2017", "cash deposit", 340.75));
uncategorizedList.add(new ExpenseList("08/01/2017", "edeposit", 30.01));
uncategorizedList.add(new ExpenseList("05/18/2017", "stephan", 1220.89));
uncategorizedList.add(new ExpenseList("03/02/2017", "bob", 20.50));
the next step is to take String[] income and see if uncategorizedList contains any of the words in String[] income. If it does, I add the date, description, and price to incomeList. The code works perfectly.
String[] income = {"edeposit", "stephan", "check deposit", "cash deposit"};
List<ExpenseList> incomeList = new ArrayList<>();
for (ExpenseList expense : uncategorizedList) {
for(int i=0; i < income.length; i++) {
if (expense.getDescription().toLowerCase().contains(income[i])) {
incomeList.add(new ExpenseList(expense.getDate(),expense.getDescription(), expense.getPrice()));
}
}
}
What I'm having a problem with is how to delete the elements from uncategorizedList that were added to incomeList. As I stated earlier, .remove() does not work. The only thing that should be left in uncategorizedList is 03/02/2017, bob, 20.50