Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forEach and hasNext()

 
Max Rahder
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I translate this into forEach? The part I can't figure out is the code that omits the delimiter for the last item:

Java version:

This sample prints something like: "Groucho, Harpo, Chico"



JSTL version:

How do I put the "has next" test inside the forEach tag?

This sample prints something like: "Groucho, Harpo, Chico, "
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the varStatus attribute of the forEach tag.
 
Max Rahder
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works great. Thanks for the tip.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic