title: how to create recursive merge of 2 sorted lists resulting in sorted merged list
body: <p>I am learning about recursion I am trying to return a sorted list by merging 2 sorted lists and am getting lost. I know this is incorrect already but any guidance will help.</p>
  
  <pre><code>public static ArrayList&lt;Integer&gt; mergeMyList(ArrayList&lt;Integer&gt; list1, 
            ArrayList&lt;Integer&gt; list2)
  {
      ArrayList&lt;Integer&gt; tempList = null;  
      int n = list1.size() +list2.size();
      int l = list2.size();
  
      if ( n == 0  &amp;&amp; l == 0)
      {                        
          tempList = list1;
          return tempList;
      }
      if ( n == 0 )
      {                        
          tempList = list2;
          return tempList;
      }
      if ( l == 0)
      {                        
          tempList = list1;   
          return tempList;
      }
  
      else
      {   
          int x = list1.get(0); 
          int y = list2.get(0);
  
          if (x &lt; y )
          {
              //  list1.add(x);
              //  list1.add(y); 
              tempList=list1;
              //  list1.remove(0);
              //  list2.remove(0);    
  
          }
          else
          {
              list1.add(y);                     
              tempList = list1;
              list1.remove(0);
              list2.remove(0);
              tempList = mergeMyList(list1,list2);
          }                   
      }
      tempList = mergeMyList(list1,list2);
      return tempList;
  } 
  </code></pre>