I have a problem understanding an exercise. I have to develope a linear linked list. But I do not have to to distinguish between list and node.
The constructor Node should create a node and prepend it to the list that is passed as a parameter.
Normally I would go through the list and append a node at the end of it. Here is my code.
class Node{ Object data; Node link; public Node(Object pData, Node pLink){ this.data = pData; this.link = pLink; } public String toString(){ if(this.link != null){ return this.data.toString() + this.link.toString(); }else{ return this.data.toString() ; } } public void inc(){ this.data = new Integer((Integer)this.data + 1); } } Maybe I have just learned to much today and my brain can't take more inforamtion:D please help!