iteration

Discussion in 'Java' started by bob, May 1, 2012.

  1. bob

    bob Guest

    What's the name of this type of iteration in Java?

    for (Player p : players)
    {

    }

    I haven't seen this until recently.
    bob, May 1, 2012
    #1
    1. Advertising

  2. bob

    markspace Guest

    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>
    markspace, May 1, 2012
    #2
    1. Advertising

  3. bob

    Arivald Guest

    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
    Arivald, May 1, 2012
    #3
  4. bob

    Roedy Green Guest

    On Tue, 1 May 2012 07:29:35 -0700 (PDT), bob <>
    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.
    ..
    Roedy Green, May 1, 2012
    #4
  5. bob

    Arne Vajhøj Guest

    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
    Arne Vajhøj, May 1, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dwerdna
    Replies:
    5
    Views:
    5,331
    Ajeetha
    Mar 31, 2005
  2. Bruce Whitehouse
    Replies:
    3
    Views:
    389
    Alvin Bruney
    Nov 23, 2003
  3. jurujuba
    Replies:
    3
    Views:
    1,543
    Eliyahu Goldin
    Feb 20, 2005
  4. =?Utf-8?B?TmlnZ3k=?=

    Dataset Iteration

    =?Utf-8?B?TmlnZ3k=?=, Jun 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    416
    =?Utf-8?B?TmlnZ3k=?=
    Jun 10, 2005
  5. Rudi
    Replies:
    5
    Views:
    4,974
Loading...

Share This Page