Java 5.0 introduced an enhanced for-loop. In this post, I'll write about it.
The enhanced for loop provides a simple structure allows one to simplify code by presenting for-loops that visit each element of an array/collection without explicitly expressing how one goes from element to element.
The new for loop makes programming simpler. For example, if you want to print each element for an array, you used to do that with a for loop in the following way: