Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #14074 > unrolled thread

iteration

Started bybob <bob@coolfone.comze.com>
First post2012-05-01 07:29 -0700
Last post2012-05-01 18:47 -0400
Articles 6 — 6 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  iteration bob <bob@coolfone.comze.com> - 2012-05-01 07:29 -0700
    Re: iteration Patricia Shanahan <pats@acm.org> - 2012-05-01 07:45 -0700
      Re: iteration Arivald <NOSPAMarivald@interia.pl> - 2012-05-01 19:39 +0200
    Re: iteration markspace <-@.> - 2012-05-01 08:59 -0700
    Re: iteration Roedy Green <see_website@mindprod.com.invalid> - 2012-05-01 13:39 -0700
    Re: iteration Arne Vajhøj <arne@vajhoej.dk> - 2012-05-01 18:47 -0400

#14074 — iteration

Frombob <bob@coolfone.comze.com>
Date2012-05-01 07:29 -0700
Subjectiteration
Message-ID<27598671.190.1335882575014.JavaMail.geo-discussion-forums@ynbq3>
What's the name of this type of iteration in Java?

for (Player p : players)
{

}

I haven't seen this until recently.

[toc] | [next] | [standalone]


#14075

FromPatricia Shanahan <pats@acm.org>
Date2012-05-01 07:45 -0700
Message-ID<dLOdnTXMZf-ZagLSnZ2dnUVZ_rCdnZ2d@earthlink.com>
In reply to#14074
On 5/1/2012 7:29 AM, bob wrote:
> What's the name of this type of iteration in Java?
>
> for (Player p : players)
> {
>
> }
>
> I haven't seen this until recently.

"enhanced for statement"

See http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.14.2

Patricia

[toc] | [prev] | [next] | [standalone]


#14087

FromArivald <NOSPAMarivald@interia.pl>
Date2012-05-01 19:39 +0200
Message-ID<jnp79h$dp5$1@news.dialog.net.pl>
In reply to#14075
W dniu 2012-05-01 16:45, Patricia Shanahan pisze:
> On 5/1/2012 7:29 AM, bob wrote:
>> What's the name of this type of iteration in Java?
>>
>> for (Player p : players)
>> {
>>
>> }
>>
>> I haven't seen this until recently.
>
> "enhanced for statement"

Yet most coders (ones capable of coding not only in Java) call it 
"foreach" or "for each".
This name exactly describe intent of this kind of loop, "execute some 
code for every element in collection".

http://en.wikipedia.org/wiki/Foreach_loop

-- 
Arivald

[toc] | [prev] | [next] | [standalone]


#14078

Frommarkspace <-@.>
Date2012-05-01 08:59 -0700
Message-ID<jnp18o$uni$2@dont-email.me>
In reply to#14074
On 5/1/2012 7:29 AM, bob wrote:
> What's the name of this type of iteration in Java?
>
> for (Player p : players)
> {
>
> }
>
> I haven't seen this until recently.


You will also get Google hits with "Java for each"

<http://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html>

[toc] | [prev] | [next] | [standalone]


#14102

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-05-01 13:39 -0700
Message-ID<3fi0q7lo1bh6j68i39mpm9qb3bp7ko62va@4ax.com>
In reply to#14074
On Tue, 1 May 2012 07:29:35 -0700 (PDT), bob <bob@coolfone.comze.com>
wrote, quoted or indirectly quoted someone who said :

>What's the name of this type of iteration in Java?
>
>for (Player p : players)
>{

I call it "for each"
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML. 
They forget that the simplest language is the one you 
already know. They also forget that their simple little 
markup language will bit by bit become even more convoluted 
and complicated than HTML because of the unplanned way it grows.
.

[toc] | [prev] | [next] | [standalone]


#14107

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-05-01 18:47 -0400
Message-ID<4fa06809$0$291$14726298@news.sunsite.dk>
In reply to#14074
On 5/1/2012 10:29 AM, bob wrote:
> What's the name of this type of iteration in Java?
>
> for (Player p : players)
> {
>
> }
>
> I haven't seen this until recently.

It came with Java 1.5 in 2004.

:-)

It is usually called "for each" or "enhanced for".

I sometimes call it "new for".

Arne

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web