Posted By:
Srikanth_Basavaraju
Posted On:
Sunday, April 11, 2004 03:18 AM
Hey check this piece of code
A1[j] = FillArray;
This is making the real difference.
Since the same FillArray is used for all the iterations hence it goes on adding 'Parag' in the same datastructure.
Hope u got it!!!
Posted By:
Aarati_Marathe
Posted On:
Tuesday, April 6, 2004 05:24 AM
what is your arg.length? If you are passing the command line parameter then your value should be args.length I assume you are passing 3 command line arguments...
Anyways here is the code which gives you the output you want
import java.util.*;
public class ArrayListTest
{
public static void main(String[] args)
{
ArrayList A1= null;
ArrayList FillArray = new ArrayList(100);
A1 = new ArrayList(args.length);
for(int j=0; j < args.length; j++)
{
A1.add("Parag");
}
for(int j=0; j < args.length; j++)
{
System.out.println(j+" : "+A1.size()+" : "+A1.get(j));
}
}
}