I came across a mock question for SCJP 1.5 from JavaBeat Mock exams ('Language features', Q6): 'Which of the following statements are true about the new enhanced for loop?' One of the answers is: 'The enhanced for loop eliminates the need for Iterator objects'. And it is said to be one of correct choices. Now I would argue that the need for iterators is not eliminated entirely with introduction of the enhanced for - e.g. let's take code scenarios, when we have to remove objects from collection during iteration. It is not possible (or at least not safe) using the enhanced for.
Do you agree that such formulation is at least a bit ambiguous? Can I expect this kind of questions / answer choices at the real SCJP?
Joined: May 17, 2008
Hmmm...well technically the statement is true because it is true in some cases, but you are right--it is poorly worded. Trying to apply a programmer's need for precision to the English language is always fraught with peril.