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!

Printing keys in a hashmap

843785Dec 16 2008 — edited Dec 18 2008
Hi, how do you loop through a hashmap and print the keys, i mtrying to cram some last min revision for a test later

so far i have a class that describes a contact with 3 fields first name surname phne number and age and a method to return all of them and one to return a string of them printed in a certain order

second class (address book )has a hashmap <String, Contact> and the practise paper says write a method that prints out the contacts using system.out.println usign the print method in the first class

so far i think im going laong the wrong lines using a key set?

Set mySet = addyBook.keySet();
for(int i = 0; i<addyBook.size(); i++){
//do something
}

can someone help me pelase, hopefully it wont come up but just in case :D
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2009
Added on Dec 16 2008
20 comments
1,168 views