title: Is there a way to copy a doubly LinkedList in Java without reference?
body: <p>I am creating some doubly linked list of type Double and no matter how I declare another linked list of the same type, it always refers to the first list.</p>
  
  <p>Such as:</p>
  
  <pre><code>LinkedList&lt;LinkedList&lt;Double&gt;&gt; trainingData = new LinkedList&lt;LinkedList&lt;Double&gt;&gt;();
  LinkedList&lt;LinkedList&lt;Double&gt;&gt; newData = new LinkedList&lt;LinkedList&lt;Double&gt;&gt;();
  </code></pre>
  
  <p>Add some things to trainingData...</p>
  
  <pre><code>newData = trainingData;  
  </code></pre>
  
  <p>Then whatever changes I make to trainingData after this assignment gets changed in newData.  I've also tried passing trainingData in the constructor of newData and using a nested loop to assign trainingData's data to newData, but it is still giving me the same results where newData references trainingData.</p>