0

What is the point of an enhanced for loop?

What is the point of an enhanced for loop when dealing with arrays? To me it seems like a regular for loop can do the same things.

17th Apr 2019, 9:22 PM
Kyara
Kyara - avatar
2 Respostas
+ 6
enhanced for simple things for-loop for complex things
17th Apr 2019, 9:37 PM
D_Stark
D_Stark - avatar
+ 2
check this from java docs. for-each is intended to provide a way to simplify (coding and readability) for iterating through iterable objects (arrays being among the easier examples). More complex examples are provided as are times when you wouldnt use it. https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html
17th Apr 2019, 10:46 PM
Tim Lynch
Tim Lynch - avatar