Enhanced for loop vs foreach loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Enhanced for loop vs foreach loop?

I was in AP computers today and we learned about the foreach loop. When I saw it I instantly thought it was the enhanced for loop. They seem to have the same syntax. What's the difference?

16th Jan 2019, 8:15 AM
Chinedu Tabansi
Chinedu Tabansi - avatar
1 Answer
+ 1
With foreach you don't need to access the elements of an array with its index
16th Jan 2019, 11:19 AM
Gordon - avatar