+ 1
Generally a for loop consists of 3 parts
1.initialization
2.condition
3.either a increment or decrement operator
But enhanced for loop is a bit different.
We use it in collections
Its syntax is like
for(classname object: referencevariable)
Here class name is the name of the class whose objects are taken into consideration for creating a collection
reference variable is the variable which points out my collection.
We will see an example which will clearly illustrate what is an enhanced for loop
import java.util.*; Â
class Testenhancedforloop{ Â
public static void main(String args[]){ Â
ArrayList<String> al=new ArrayList<String>(); Â
 al.add("Ravi"); Â
 al.add("Vijay"); Â
 al.add("Ravi"); Â
al.add("Ajay");Â Â
 for(String obj:al) Â
System.out.println(obj);Â Â
 } Â
}Â Â