title: duplicating a node in a linked list java
body: <p>just to start off, this is homework and thank you for your assistance ahead of time. I keep getting stuck on little problems so I am hoping you guys can help me with one. What I am trying to do is create a linked list that has multiples functions. The one I am having trouble with is sorting(I can do the other ones). Each node holds a string, an integer and a double. I need to be able to sort by each of these and by the order it was inputted, on the user's request. ***It is also important to mention that the variables in my object are private and my object is called list1. Basically, I have to make one linked list for the chronological order and one for each other order. </p>
  
  <p>My plan is to insert the nodes in their correct order as the user inputs them. So as the user inputs a node, that node needs to go in the correct place in the chronological list and in the other lists. So, I need to copy the node to do this. However, I cannot simply just say </p>
  
  <pre><code>icopy(copy for integer) = newNode(node the user just inputted)
  </code></pre>
  
  <p>That only changes the address. When I went to my instructor he told me that I should say:</p>
  
  <pre><code>    icopy.data = newNode.data;
  </code></pre>
  
  <p>("data" being the shortcut way of mentioning that I need to get the individual data types within the node.) So I wrote:</p>
  
  <pre><code>    icopy.GetI() = newNode.GetI();  
  </code></pre>
  
  <p>When I do this I encounter this error: <strong>unexpected type required:variable, found:value.</strong> I am not sure what to do. Any assistance would be appreciated and I would be happy to clarify anything. </p>
  
  <p>*GetI: method in my object that gives access to the integer value in each node.<br>
  *p: pointer for the Chronological<br>
  *pi: pointer for the integer.<br>
  *fi: front of the integer linked list  </p>
  
  <pre><code>  public static void main(String args[])
    {
      String repeat = "y";
      boolean inserted = false;
      list1 fChr = null;
      list1 p = fChr;
      list1 icopy = null;
      list1 scopy = null;
      list1 dcopy = null;
      list1 fd = fChr;//front of the double list
      list1 fi = null;//front of the integer list
      list1 fStr = fChr;//front of the string list~
      while(repeat.equals("y"))//while the user agrees to adding a new node
      {
          if(fChr == null)// if the front is empty
          {
              fChr = new list1();//create a new node by calling object and sets it as the front
          }
          else
          {
              p = fChr;
              while(p.next != null)//finds the end of the Linked list
              {
                  p = p.next;//moves the pointer p down the list
              }
              list1 newNode = new list1();
              icopy.GetI() = newNode.GetI();// make a copy of newNode
              p.next = nexNode;//put in chronological order
              while(p != null)
              {
                  if(fi == null)
                  {
                      fi = n;
                  }
                  else if(n.GetI() &lt; fi.GetI)//check at beginning
                  {
                      //put at beginning
                  }                    
  
                  else if(icopy.GetI() &lt; p.next.GetI())//check in between nodes
                  {
                      //put in between
                  }
                  //does it go at the end
              }
          }
          repeat = JOptionPane.showInputDialog("Would you like to add a node [y/n]");
      }
      PrintMenu(fChr, fi, fd, fStr);// sends the user to the menu screen
  }
  </code></pre>