Oracle Certified Professional, Java SE 6 Programmer.
Agustin John Lacson
Joined: Sep 18, 2012
Ohh thanks for the tip but since I'm kinda new I don't know how to use any of those. Can you demonstrate using a pseudo code or something? just something that can show me how I can loop through given my circumstances...
Agustin John Lacson wrote:how do I loop through the map to display the person's name (key), and their corresponding birthdates?
Well, first: you need to read up on three methods provided by all Java Maps:
keySet() values(), and
entrySet() and then look at Aniket's post again.
You can use either of the first two styles he lists to do what you want, since they work for ANY Java collection (ListIterator only works for Lists; and I wouldn't use Enumeration at all - it's old-fashioned - although it is worth knowing that it exists).
For your needs, I have a slight preference for using entrySet() and a for-each loop, but that's just my opinion.
Isn't it funny how there's always time and money enough to do it WRONG?