title: adding elements of another arraylist by recursion-java
body: <p>Here is a method that is supposed to simply create a new ArrayList copying all the elements of parameter ArrayList arrlist, which I think I've done correctly.</p>
  
  <pre><code>public ArrayList&lt;T&gt; copy (ArrayList&lt;T&gt; arrlist) {
          ArrayList&lt;T&gt; um=new ArrayList&lt;T&gt;();
          for (int i=0;i&lt;arrlist.size();i++)
              um.add(arrlist.get(i));
          return um;
  </code></pre>
  
  <p>However, I'd like to write this exact same method using recursion only with no loops. Here is what I wrote. The copy method uses a recursive helper method.</p>
  
  <pre><code>public ArrayList&lt;T&gt; copy(ArrayList&lt;T&gt; arrlist) {
      return copy(arrlist,0); 
  }
  
  private ArrayList&lt;T&gt; copy(ArrayList&lt;T&gt; arrlist, int n) {
      ArrayList&lt;T&gt; um=new ArrayList&lt;T&gt;();
      if (n&lt;arrlist.size())
          um.add(list.get(n));
      return copy(list,n+1); 
  }
  </code></pre>
  
  <p>Except this does not work. Any suggestions or hints?</p>