How do I reverse an ArrayList ?
I am trying to figure out how to write a method that will reverse an ArrayList. I can't use collections.reverse(). I'm lost, my teacher speaks broken English so I'm basically on my own here. I think that I should use a for loop, something like this:
for (int index = arrayList.size(); index = 0; index--)
But, I don't understand how to make it return the reversed arrayList. Any help is appreciated.
Re: How do I reverse an ArrayList ?
You could do it in a loop. Take a piece of paper and a pencil, draw some objects on a row representing the objects in the arraylist. Use indexes/pointers (one at each end) and work out the logic for reversing the contents.