I think it is important to set clear that not all
Java Collections use array to store data (for instance
java.util.LinkedList does not).
Another important thing to take into account is that altough HashMap does use an array to store the data, when you delete an element, behind the scenes, that index in the underlying array is set to null, so that the actual object can be garbage collected.
The previous post seems to suggest that there is no problem in holding that information in memory, which would be a bad idead.
You can learn more about this reading
Effective Java by Joshua Bloch, see the Item 5: Eliminate obsolete references.
The
HashMap is a clear example of this. See in the source code of the HashMap the method
clear(), to illustrate this explanation.
[ October 04, 2006: Message edited by: Edwin Dalorzo ]