For a ClassProject we have to write our own Linkedlist with all its methods. The method i am posting now is simply putting an Object with its Data and 2 referrences (prev / next) at the end of the list.
Node addObject(Object o) {
Node item = new Node (o);
Node node = head;
while(node!=null) {
if(node.getNext()==null) {
node.setNext(item);
item.setPrev(node);
}
node = node.getNext();
}
The question for me is, and not just for this method, what is item.next pointing on now, is it initially NULL ? I did not initializies it with NULL in the Node Objekt. Does it need a pointer in it like item.setnext(NULL) ?