• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loops  RSS feed

 
Ana Reyes
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When can you use the for/in loop? Is there a certain order you must follow ?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ana Reyes wrote:When can you use the for/in loop? Is there a certain order you must follow ?


What's a for/in loop? Can you elaborate your question with a code snippet, as it's not clear what you mean by 'certain order'
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know the Java Tutorials sections are rather short, but have you read about the for statement?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ana Reyes wrote:When can you use the for/in loop? Is there a certain order you must follow ?

I think the OP may be referring to the "for each" loop...it is often read out loud as "for each A in B".

but that is a guess...
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:I think the OP may be referring to the "for each" loop...it is often read out loud as "for each A in B".

@Ana: And if that's the case, then you can use it on an array, or any object that implements the Iterable interface - which includes all Lists, Sets, and Collections.

HIH

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!