+ 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);    }   }  
14th Dec 2017, 1:28 PM
BHEEM REDDY SAI KUMAR
BHEEM REDDY SAI KUMAR - avatar