| Author |
For each loop
|
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4354
|
|
(Question Java Tiger) concern the code in bold: i guess the method values() is executed once (at the beginning of the loop) and not every time a new value is assigned to variable kolom, because that would be a performance problem
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Steve Morrow
Ranch Hand
Joined: May 22, 2003
Posts: 657
|
|
|
Values is only called once (in order to get at an Iterator).
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
The values() method returns a Collection, and to iterate through that collection an Iterator is obtained from kolommen.values().iterator(). That's done only once, exactly as in the first part of a normal for loop:
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4354
|
|
Originally posted by Barry Gaunt: The values() method returns a Collection, and to iterate through that collection an Iterator is obtained from kolommen.values().iterator(). That's done only once, exactly as in the first part of a normal for loop:
that's exactly what my .class file looks like after i decompiled it (i thought too late about that option to verify my ideas (it's almost weekend so the brain is slowing down )
|
 |
 |
|
|
subject: For each loop
|
|
|