File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Array reverse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Array reverse" Watch "Array reverse" New topic

Array reverse

michael micky

Joined: May 31, 2011
Posts: 4
how to display an array in reverse using enhanced for loop?
Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

Hi Michael. Welcome to The Ranch!

If you want to use the enhanced loop, I think you'll need to reverse the order of the array first. The Collections class has a method for reversing a list: you could always convert it to a list and use that.

But personally, I'd just write an old-fashioned for loop and step backwards.
michael micky

Joined: May 31, 2011
Posts: 4
well thnx Mr.Matthew Brown this is perfect......................
I agree. Here's the link:
subject: Array reverse
It's not a secret anymore!