• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array reverse

 
michael micky
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to display an array in reverse using enhanced for loop?
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well thnx Mr.Matthew Brown this is perfect......................
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic