Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > iteration

Reply
Thread Tools

iteration

 
 
bob
Guest
Posts: n/a
 
      05-01-2012
What's the name of this type of iteration in Java?

for (Player p : players)
{

}

I haven't seen this until recently.
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      05-01-2012
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>


 
Reply With Quote
 
 
 
 
Arivald
Guest
Posts: n/a
 
      05-01-2012
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
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-01-2012
On Tue, 1 May 2012 07:29:35 -0700 (PDT), bob <(E-Mail Removed)>
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.
..
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-01-2012
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts - Problem with nested iteration or double iteration Rudi Java 5 10-01-2008 03:30 AM
Dataset Iteration =?Utf-8?B?TmlnZ3k=?= ASP .Net 0 06-10-2005 02:25 PM
Showing value of loop iteration in assert statement dwerdna VHDL 5 03-31-2005 05:23 PM
implementing iteration- and conditional-tags with ASP.NET jurujuba ASP .Net 3 02-20-2005 08:16 AM
looping and displaying progress with every iteration Bruce Whitehouse ASP .Net 3 11-23-2003 07:15 PM



Advertisments