Going to infinite loop when using iterator
843789May 26 2009 — edited May 26 2009Hi Friends,
Below is the piece of code for reference. My while loop goes into infinite loop.
I am not able to understand why?
Plese help...
Thanks & Regards,
Sanjeev
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
public class Test {
public static void main(String[] args) {
HashMap multiLingualData= new HashMap();
multiLingualData.put("1","100");
Set keySet = multiLingualData.keySet();
System.out.println("Hash Map="+multiLingualData);
System.out.println("keyset size="+keySet.size());
System.out.println("keySet= "+keySet);
while(keySet.iterator().hasNext())
{
System.out.println("hellooooooooo");
}
}
}