Friday, 11 March 2016

ArrayList To Array conversation 2

import java.util.*;
class ArrayListToArray
{ public static void main(String[] args)
{ ArrayList al=new ArrayList();
al.add(new Integer(1));
al.add(new Integer(2));
al.add(new Integer(3));
al.add(new Integer(4));
System.out.println("Contents of al : "+al);
System.out.println("Contents of al using iterator:");
Iterator itr = al.iterator();
while(itr.hasNext())
{
int x = (Integer)itr.next();
System.out.print(x + " ");
}
}
}

No comments:

Post a Comment