The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

How to reverse a string array ?

Hello again. I have an array of friends names and I want to print it in reverse. I know this question seems a bit lazy, but i really have tried casting the string as ints and even using lazy = String,valueOf(i) etc but No luck so far. Thanks

Re: How to reverse a string array ?

The enhanced for loop is a great tool, and I'm impressed that you're using it already, but unfortunately, it only iterates the collection in the forward direction. You'll have to write a loop, usually the standard for loop, to iterate the array in the reverse direction. Can you do that? Can you write a standard for loop in the forward direction? If so, start with that, and think about how you'd write it to go in the reverse direction. If you need help, show what you can do and ask for help.