• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is this? Is it a type of For loop?  RSS feed

 
raghav singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would like to know what is this:

for (String element : myArray) {
}

Can someone explain to me how it work? Is it a for loop? Does this code have a name i mean how is this code structure called?

Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, search "enhanced for loop".
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
 
Sooraj Rajagopalan
Ranch Hand
Posts: 40
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Particularly effective when dealing with Collections in java.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am pleased to see an Oracle link saying for‑each. Far better name than enhanced for. I had seen the link before; I remember the bit about saying, “for each XX in YY”.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!