title: How to copy Java object without a change to the original affecting the copy
body: <p>In the function addStartNode, I create a new Node 'temp' whose value is set to equal that of 'head'. Then I set head to be a new Node with value different 'v'.</p>
  
  <p>However, when I print both the values for 'temp' and 'head', it displays the same thing.</p>
  
  <p>I've tried many different approaches to this, including a copy constructor, but it doesn't seem to be changing anything.</p>
  
  <p>Any help would be great!</p>
  
  <pre><code>public class DoublyLinkedList {
  
      private static class Node {
  
          private static int value;
  
          Node(int v) {
              value = v;
          }
  
          int getValue() {
              return value;
          }
      }
  
      private static Node head;
  
      void addStartNode(int v) {
          if (head == null) {
              head = new Node(v);
          } else {
              Node temp = new Node(head.getValue());
              PRINT VALUES HERE
              head = new Node(v);
              PRINT VALUES HERE
          }
      }
  }
  </code></pre>