Node inside a linkedlist
SomeInterface has an addLast() method that should add a node at the end of the list
public LinkedList<T> implements SomeInterface<T>{protected class Node<T>{
privateT data;
private Node<T> head,tail;
protected Node(T data,Node<T>tail){
this.data=data;head=null;this.tail=tail;}
private T getInfo(){return this.data;}
private void setTail(Node<T>newTail){this.tail=newTail;}
private void setLink(Node<T>newHead){this.head=newHead;}
private Node<T> getLink(){return tail;}
}}
public void addLast(){
}
}//end of LinkedList<T> class
when I create a LinkedList object (LinkedList<String>somelist=new LinkedList<T>()
) and try to append multiple items (somelist.append("William");somelist.append("Fredk rick"
);somelist.append(Maria
)) only the last item/string gets appended to the list. Any reason why?