This seems like a simple problem but I am having trouble nonetheless.
So I know the indexes of the items I want to remove but if I put this in a loop and try to use the remove(index) call - that works fine for the first one - but since there was already one removed - now the indexes are screwed up for the following remove calls.
I would also like for the new list ( the one minus the removed lines) to be in the same order as the orginal list - (minus the removed lines, of course)
What is the elegant/easy way to do this? Convert arrayList to another object or what? This has to be a common problem.
what if you remove the items starting from the back of the list? That way you won't screw up the indexing for the items that you haven't yet removed.
posted 12 years ago
Cool - thanks for the fast, thorough response.
Yes, I actually tried this method, during a coding frenzy - and typical of programming - this particular piece of code must have been working but another method call after that was skewing my result - so I was barking up the wrong tree - wish I had a dollar for every time I have done that.
no wonder he is so sad, he hasn't seen this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user