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!

Going to infinite loop when using iterator

843789May 26 2009 — edited May 26 2009
Hi 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");
}

}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 23 2009
Added on May 26 2009
6 comments
2,930 views