posted 13 years ago
When we say any collection is ordered, it means that when you iterate over the collection, the output is predictable. For example if I have the following code
If I iterate over this ArrayList, I know that "A" will be the first element to be iterated, then "B" then "C" and then "D". So I can predict the iteration sequence. This means that the collection is ordered (insertion order in case of ArrayList). But if you iterate over a HashMap, you can't predict the iteration order because HashMap doesn't guarantee any iteration order. So you can't predict in which order elements will be iterated in a HashMap and thus its unordered...