jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes ListIterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ListIterator" Watch "ListIterator" New topic


R Jarman

Joined: Feb 08, 2005
Posts: 27
I'm using a ListIterator to parse through an ArrayList. I understand how to use it to parse the entire array but what if I'm looking for something in the array? Once I find the object I want to do some processing on it and I don't want to parse the rest of the array. How can I punch out of an ListIterator once a condition has been met or am I better off using the old way with for loops or while loops?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Just don't call "next" anymore. Use "break" to escape out of your loop.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link: http://aspose.com/file-tools
subject: ListIterator
It's not a secret anymore!