Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ListIterator  RSS feed

 
R Jarman
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just don't call "next" anymore. Use "break" to escape out of your loop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!