A while ago I implemented a LinkedList in C. It was pretty straight forward since each Node was made of a value and another pointer to the next element in the list. But now I am trying to implement a LinkedList in Java, since there are no pointer I made a Node like this:
public class MyNode{
    int value;
    MyNode next;
    public MyNode(int i){
        value = i;
        next = null;
    }
}
Now lets say I have this:
MyNode n1 = new MyNode(1);
MyNode n2 = new MyNode(2);
n1.next = n2;
MyNode n3 = new MyNode(3);
n2 = n3;
What would I get if I do
System.println(n1.next.value);
Would I get a 2 or a 3? My main problem coming from C is that I do not really understand how java moves around the data. Does it copy n2 to n1 or does n1 just point to n2? This is all really confusing.
 
     
     
     
    