Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
For Each Loop Doubt
vidya sagar
Ranch Hand
Posts: 580
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
String names[] = {"vidya","sagar","Raj","kumar"}; for(String e:names) { System.out.println(e); }
Its a Block of Code.
Now i want to iterate in a reverse order.Is it possible.If so how??
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Reverse the array before the loop
[My Blog]
All roads lead to JavaRanch
Campbell Ritchie
Marshal
Posts: 79177
377
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Standard beginner's exercise.
Don't use a for-each loop. Use
for (int i = myArray.length - 1; i >= 0; i--) etc
CR
[ June 22, 2006: Message edited by: Campbell Ritchie ]
vidya sagar
Ranch Hand
Posts: 580
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks satou and Campbell for your replies
Just i want to know whether iterating values in reverse order is possible or not through For Each loop
Jesper de Jong
Java Cowboy
Posts: 16084
88
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The for each loop syntax does not have any special syntax or other mechanism to specify that you want to loop in the reverse order, so the answer to your question is no.
Jesper's Blog
-
Pluralsight Author Page
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to sovle these two errors~~~help~~~
what is the difference between String and other reference types?
retreiving the session attribute value from anoher Action class
How String Can Be A Reference Variable...
blackberry pearl 8100
More...