• Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting an arraylist?  RSS feed

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know i can use .indexOf and lastIndexOf to obtain the first and last position of an element. However, I also want to find the other indexes in the arraylist between the start and the beginning.

Would it be best to, when having found the first position in the arraylist to split at the point to leave me with the rest of the array list yet to consider so i can use .indexOf again to find the next position? If so, how can this be done?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use List's subList method to obtain sublists to search, but it's easier just to loop through the original list.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!