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.
2 Respuestas
+ 6
enhanced for simple things
for-loop for complex things
+ 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