For example, Let's say I have the code below:
ArrayList<String> A1 = new ArrayList<>();
A1.add("Hello");
A1.add("World");
A1.add("!");
Then I perform the following actions:
A1.remove(2);
So A1 is now ["Hello", "World"].
But how do the compiler perform this action? What will the pointer that points to "!" before point to after I perform the delete action? Apparently A1.get(2) is now an illegal operation and will cause IndexOutOfBounds Exception, and A1.size = 2. What happens to the space that is allocated for 3rd slot of the list in memory and how are all these processed at lower level?
Thank you!