[Solved] Check the code. Don’t understand why logic not work totally [closed]
Not quite clear on your code, but when you remove an element from an ArrayList that you are iterating through, you do not want to increment the index, otherwise you will skip elements, e.g.: ArrayList<…> list = …; for (int i = 0; i < list.size(); ) { if (shouldBeRemoved) list.remove(i); else ++ i; } … Read more