Printing keys in a hashmap
843785Dec 16 2008 — edited Dec 18 2008Hi, 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