• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to revert ArrayList!

 
Peter Heng
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Collection line = new ArrayList();

line.add("line1");
line.add("line2");
line.add("line3");
line.add("line4");
line.add("line5");

How can I revert the list above become as below:

line5
line4
line3
line2
line1

Thanks...
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Collections.reverse
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic