Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Iterating through entrys of HashMap

807597Apr 26 2005 — edited Mar 16 2007
I have a HashMap that is already populated. I'm iterating through the entrySet and want to get the keys and values and use them to create another object. I've searched the forum and googled but can't quite seem to find what I need. Here's the code I have so far.
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
if (iterator.next() != null) {
	reasonsList.add(new DropDownData(key, value)); // here's where I'm not sure what to do
}
}
The DropDownData object accepts twos strings, one for the key and one for the displayed value. These strings should be the key and value from my current HashMap entry. But I can't seem to figure out how to do it.

thanks for any help/suggestions
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2007
Added on Apr 26 2005
12 comments
920 views