Enhanced Loop Example in Java


Here is the simple program for printing basic example using Enhanced For Loop in Java.

Source Code

import java.io.*;
import java.util.Scanner;
class enhan_for
{// Tutor Joes Computer Education
  public static void main(String args[])
  {
   int i;
   //String name[]={"Ram","Tutor","Joes","Sam","raja"};
  String [] name =new String[10];//name[10]
  name[0]="Ram";
  name[1]="Sam";
  for(i=0;i<2;i++)
  {
    System.out.println("For : "+name[i]);
  }
  for(String temp : name)
  {
    System.out.println("En-For : "+temp);
  }
  }
}
To download raw file Click Here

Output

For : Ram
For : Sam
En-For : Ram
En-For : Sam
En-For : null
En-For : null
En-For : null
En-For : null
En-For : null
En-For : null
En-For : null
En-For : null


Learn All in Tamil © Designed & Developed By Tutor Joes