I wrote below code to retrieve values in hashmap. But it didnt work.
HashMap<String, String> facilities = new HashMap<String, String>();
Iterator i = facilities.entrySet().iterator();
while(i.hasNext())
{
String key = i.next().toString();
String value = i.next().toString();
System.out.println(key + " " + value);
}
I modified the code to include SET class and it worked fine.
Set s= facilities.entrySet();
Iterator it = facilities.entrySet().iterator();
while(it.hasNext())
{
System.out.println(it.next());
}
Can anyone guide me what went wrong in above code without SET class??
P.S - I do not have much programming exp and started using java recently