I am supposed to implement a recursive linked list, but after writing the code and debugging, it seems that my front node is remaining unchanged (it is staying at null). Any help will be appreciated.
public class RecursiveLinkedCollection<T> implements CollectionInterface<T> {
LLNode<T> front;
int size = 0;
RecursiveLinkedCollection() {
front = null;
size = 0;
}
private LLNode<T> recAdd(LLNode<T> node, T data) {
if(node == null) {
LLNode<T> newNode = new LLNode<T>(data);
node = newNode;
}
if(node.getLink() == null) {
LLNode<T> newNode = new LLNode<T>(data);
node.setLink(newNode);
return newNode;
}
return recAdd(node.getLink(), data);
}
@Override
public boolean add(T data) {
recAdd(front, data);
return true;
}
}