Pass reference to ArrayLists to a method.

Posted by bhavna raghuvanshi on Stack Overflow See other posts from Stack Overflow or by bhavna raghuvanshi
Published on 2010-06-16T11:12:05Z Indexed on 2010/06/16 11:32 UTC
Read the original article Hit count: 142

Filed under:
|

here is the whole program: 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 int merge(ArrayList x, ArrayList y) { List all = new ArrayList();

  all.addAll(x);
  all.addAll(y);
  System.out.println(all);

return all; }

} also tell me how do i call the function merge?

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner