i need a code to merge two ordered list of objects of integers.the method should receive references to each of the list objects to be merged , and should return a reference to merged list object.
I thought you wanted lists of Integers? Where did you copy this from (not that it's very good, BTW). Simply use the "addAll" method from the Collections class, see the API docs. And, of course, put the code into it's own method (as the description says). Retuning a reference, is, obviously, returning the "new" list. Retreiving input from users is something else, entirely, and you already have another thread on that.
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 +"] :" );
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 +"] :" );
List<Integer> all = new ArrayList<Integer>();
i coded this.
but its not taking the values from user.
pls tel me where did i go wrong????