consider the following code:
import java.util.*;
class ArrayDemonstration
{
public static void main(
String args[])
{
ArrayList list = new ArrayList(2);//line 1
list.add("mango");
list.add("apple");
list.add("mango");
list.add("banana");
Iterator i = list.iterator();
while(i.hasNext())//line 2
{
System.out.print(i.next());//line 3
}
}
}
On the above program i have some queries:
1.In the line marked with line1 the 'ArrayList ' has to accept only 2 elements but its accepting more than 2 elements .I would like to know whether its advisable to place the total no of elements in the 'ArrayList'
2.I would like to know the functionality of the lines marked with line2,line3
tx in advance,
carl..