This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Reversing an ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reversing an ArrayList" Watch "Reversing an ArrayList" New topic
Author

Reversing an ArrayList

K Sujit
Ranch Hand

Joined: Mar 23, 2005
Posts: 33
Suppose my arraylist contains objects
ob2, ob3,ob5 and ob1
I want to reverse the order of the objects in the ArrayList.
That is I want it to be
ob1, ob5, ob3 and ob2.

is there any function like(though I didn't find in Javadoc)
arrayListInstance.reverse();


I wish java run in my veins.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42047
    
  64
Try Collections.reverse(arrayList);


Ping & DNS - my free Android networking tools app
 
GeeCON Prague 2014
 
subject: Reversing an ArrayList