how to merge two ordered list of objects?
- by bhavna raghuvanshi
public class ListMerge
{
public static void main( String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println ("Input length of arraylist 1:");
int n = input.nextInt();
ArrayList x = new ArrayList();
ArrayList y = new ArrayList();
for (int i = 0; i < n; i++)
{
System.out.println ("Input x[ " + i +"] :" );
x.add(new Integer(i));
}
System.out.println ("Input length of arraylist 2:");
int m = input.nextInt();
for (int i = 0; i < m; i++)
{
System.out.println ("Input y[ " + i +"] :" );
y.add(new Integer(i));
}
List<Integer> all = new ArrayList<Integer>();
all.addAll(x);
all.addAll(y);
System.out.println(all);
}
}
I did this
but its not taking values from user.
pls tell me why....