File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 24195

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

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: ListIterator
It's not a secret anymore!