Computer Science, asked by vishaladiyandra, 1 year ago

syntax for "for each" in java

Answers

Answered by NightFury
1
The foreach loop, added in Java 5 (also called the "enhanced for loop"), is equivalent to using a java.util.Iterator --it's syntactic sugar for the same thing. Therefore, when reading each element, one by one and in order, a foreach should always be chosen over an iterator, as it is more convenient and concise
Similar questions