for each loop

The enhanced (extended) for loop in java is called  the for each loop. It is useful for iterating an array.
Syntax:
for (type var : array)
{
statements;
}
Example:
for (String value : args)
{
System.out.println(value);
}
Working of loop:
The loop function body contains only one statement "type var : array". The loop iterates till the array contains elements. At each iteration of the loop the array traversed to each of its index such as args[0], args[1],args[2]......etc. Note that here we use the colon operator (:)  not the assignment operator (=).
If there is no further elements in the array for iteration then the loop exit from further execution. Consider the following example to know more about the for each loop in java.
  

class ForEachDemo
{
public static void main(String args[])
{
for(String value : args)
{
System.out.print(value);
System.out.print("\t");
}
}
}

Output: