title: Append several NodeLists in Java
body: <p>I've been trying for hours to append three NodeLists and failing. Can you please help me?</p>
  
  <p>I've made following code:</p>
  
  <pre><code>NodeList nList = root.getElementsByTagName("res");
  NodeList nList2 = root.getElementsByTagName("agr");
  NodeList nList3 = root.getElementsByTagName("rag");
  
  NodeList allNodes = appendNodeLists(nList, nList2, nList3);
  </code></pre>
  
  <p>and the appendNodeLists method:</p>
  
  <pre><code>   public static NodeList appendNodeLists(NodeList a, NodeList b, NodeList c)
     {
       NodeList nList;
         int aSize = a.getLength();
         int bSize = b.getLength();
         int cSize = c.getLength();
         if(aSize&gt;0)
         {
             for (int i = 0; i &lt; aSize; i++) 
                 nList.item(i) = a.item(i);  //Error in this line
         }
         if(bSize&gt;0)
         {
             for (int i = 0; i &lt; bSize; i++) 
                 nList.item(aSize+1+i) = b.item(i); //Error in this line                    
         }
         if(cSize&gt;0)
         {
             for (int i = 0; i &lt; bSize; i++)
                 nList.item(aSize+bSize+1+i) = c.item(i);  //Error in this line            
         }
  
         return nList;
     }
  </code></pre>
  
  <p>What am I doing wrong? I can't append the 3 NodeLists and I can't seem to figure out why.</p>
  
  <p>Btw, I have the same error in 3 lines: "Unexpected type - required variable - found value".
  Why is this happening?</p>