[Solved] How Java ArrayList works internally [closed]
If you pass an ArrayList to a function it passes a pointer back to the original list. That means any updates in the method will be updating your original ArrayList because they are the same thing. ArrayList<String> list2 = new ArrayList<String>(list); That makes a copy of list and saves it into list2. list and list2 … Read more