package collect;
import java.util.*;
class testcollect1
{
public static void main(String args[])
{
ArrayList<String> al=new ArrayList<String>();//creating arraylist
al.add("Ajay");//adding object in arraylist
al.add("Ravi");
al.add("Sanjay");
al.add("Vijay");
Iterator<String> itr=al.iterator();//getting Iterator from arraylist to traverse elements
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
}
import java.util.*;
class testcollect1
{
public static void main(String args[])
{
ArrayList<String> al=new ArrayList<String>();//creating arraylist
al.add("Ajay");//adding object in arraylist
al.add("Ravi");
al.add("Sanjay");
al.add("Vijay");
Iterator<String> itr=al.iterator();//getting Iterator from arraylist to traverse elements
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
}
No comments:
Post a Comment