Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jstl: go backwards on foreach?

 
Phil Smy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyway to iterate backwards over a set? i.e. instead of getting items 1 -> 10, I want to go from 10 -> 1.
TIA
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is ahandy Collections.reverse(List) method, but isn't too handy when applied to a Set. If you're prepared to step away from JSTL you can use

and you can now iterate the list, which represents the reverse order that would have been returned from the Set.
Dave
 
Phil Smy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave, but unfortunately I am iterating over xml data, there is no collection around!
I am doing an x:forEach.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic