As the
reference says:
Quote:A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only instead of accessing elements with a numeric index, a String is used.
You may have your reasons to use a HashMap and not a simple Array. It all depends on what you want to do...
The thing is, since it is a HashMap (and not an Array), you cannot iterate through it as you would do with an Array. You need an Iterator.
An iterator is just a tool that will help you to retrieve each element of the HashMap. It's a three-step procedure :
1. get an iterator from the hashmap
2. see if it can retrieve the next element
3. get the next element and back to step #2
You would do quite the same with an array (but the syntax is different, because Arrays and HashMaps are different) :
1. get the array's length
2. see if you have reached this length
3. get the current element and back to step #2