File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Why is this hashmap iterating through an infinite loop? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why is this hashmap iterating through an infinite loop?" Watch "Why is this hashmap iterating through an infinite loop?" New topic
Author

Why is this hashmap iterating through an infinite loop?

Patrick Noah
Greenhorn

Joined: Aug 22, 2011
Posts: 28
I am writing a method to determine whether two strings are anagrams of one another. I am trying to print out the contents of my hashmap to debug it but am encountering an infinite loop. Can someone please tell me why this is happening? Thank you.
Alexander Sales
Ranch Hand

Joined: Feb 21, 2011
Posts: 89

Is this part reliable?



OCPJP 6, OCEWCD Java EE 6
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

Every time you call iterator() you get a new one, so you reset the position. So you need to keep calling next() on the same Iterator.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is this hashmap iterating through an infinite loop?
 
Similar Threads
JFormattedTextField with 6 integers and 2 decimals
Struggling with String Processing task
Index of the last character of Strings
equals()
HashMap