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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reversing an ArrayList" Watch "Reversing an ArrayList" New topic

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)

I wish java run in my veins.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
Try Collections.reverse(arrayList);
I agree. Here's the link:
subject: Reversing an ArrayList
It's not a secret anymore!