Pass reference to ArrayLists to a method
<p>here is the whole program:</p>

<pre><code>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 &lt; 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 &lt; m; i++)
        {
            System.out.println ("Input y[ " + i +"] :" );
            y.add(new Integer(i));

        }


  }
 list int merge(ArrayList&lt;int&gt; x, ArrayList&lt;int&gt; y) 
  {
     List&lt;Integer&gt; all = new ArrayList&lt;Integer&gt;();

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

   return all;
  }

}
</code></pre>

<p>also tell me how do i call the function merge?</p>
