import java.util.*;
class GenericArrayList
{ public static void main(String[] args)
{ ArrayList<Integer> al=new ArrayList<Integer>();
al.add(1); //Auto Boxing
al.add(2); //Auto Boxing
al.add(3); //Auto Boxing
al.add(4); //Auto Boxing
System.out.println("Contents of al : "+al) ;
System.out.println("Iterating using for-each loop");
for(int i : al) //Auto Unboxing
{
System.out.print(i + " ");
}
}
}
Comments
Post a Comment