for(String name: contact){
System.out.println(contacts.keySet());
You cannot do that,
contacts
is not a list of
String
s, it is a map of
Key, Value
pairs. So you need something like:
for (String s : contacts.keySet())
I already gave you two lonks to the HashMap methods, you should also go to
Java HashMap[
^] and
The Map Interface (The Java™ Tutorials > Collections > Interfaces)[
^], which is the parent of the HashMap. Both of these pages give sample code and explanations.