This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Iterator and user defined collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Iterator and user defined collections" Watch "Iterator and user defined collections" New topic
Author

Iterator and user defined collections

Komal Amaresh
Ranch Hand

Joined: Oct 06, 2008
Posts: 67
Sir,

Can't the iterator be used with user defined collections.

In my code the for each loop is showing the result but the with the iterator, neither the program terminates nor does it give any output

Thanks in advance,
regards,
Komal
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24189
    
  34

Perhaps you can show us the code you're using "with the Iterator" -- maybe we can tell you where you're going wrong.


[Jess in Action][AskingGoodQuestions]
Komal Amaresh
Ranch Hand

Joined: Oct 06, 2008
Posts: 67
Sorry,

i was running an infinite loop.
had put a semicolon after(while(itr.hasNext());).....big blunder.

regards,
komal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Iterator and user defined collections
 
It's not a secret anymore!