title: How to make an addAll() or addRange() method from scratch in java?
body: <p>I'm trying to do a linkedlist for an assigment i have, this ask explicitly to create, from scratch a linkedlist and some derivated types like a queue and a stack, this is just some college homework, and i realize how to make a node class and a linkedlist class, but i'm struggling to create the addAll() method in this linkedlist class, this is what i have.</p>
  
  <p>if i must bet, i say is the Collection c one, but then, i'm trying to add list of stuff there, in order to pass him's content to the new list, obiusly is not ready and obiusly doesn't work.</p>
  
  <p>Can you tell me how i can pass some kind of "proto-list" in order to pass them data inside the new list?</p>
  
  <p>(I know i must use somekind of for(objects) but i'm failing to pass some data through the parameter, which will be the right parameter to put there?)</p>
  
  <pre><code>public boolean addAll(Collection c) {
          for (int i = 0; i &lt; (this.listaNodos.size()); i++) {
  
              //for (T someT : c){
              //  Node newNodo = new Node(someT);
              //}
  
              //i know the one down there is not gonna do anything, because
              //i'm not accesing the data, but one problem at a time would ya ;)
              Node newNodo = new Node(someT);
              Node actualNodo = this;
              boolean processFinished = false;
  
              try{
                  if(index &gt;= this.listaNodos.size() || index &lt; 0){
                      throw new IndexOutOfBoundsException();
                  }
  
  
                  do{
                      if(index == actualNodo.getIndex())
                      {
                          actualNodo.setData(someT);
                          processFinished = true;
                          return true;
                      }
                      else
                      {
                          actualNodo = actualNodo.nextNode;
                      }
                  }while(!processFinished);
                  return false;
              }catch(IndexOutOfBoundsException ex)
              {
                  throw ex;
              }
          }
          return false;
      }
  </code></pre>
  
  <p>Can you tell me how to fix it to make it work?</p>
  
  <p>Any request for clarification, constructive comment, or question would be greatly apreciated too.</p>
  
  <p>Thanks in advance</p>