Skip to content

Instantly share code, notes, and snippets.

@gabrielfern
Last active June 22, 2017 03:33
Show Gist options
  • Save gabrielfern/9744c43bd4a068f565af4c8a65f4bc98 to your computer and use it in GitHub Desktop.
Save gabrielfern/9744c43bd4a068f565af4c8a65f4bc98 to your computer and use it in GitHub Desktop.
remove - recursive linked list
@Override
public void remove(T element) {
if (element != null) {
if(!isEmpty()) {
if(this.getData().equals(element)) {
this.setData(this.getNext().getData());
if(!this.getNext().isEmpty()) {
this.setNext(this.getNext().getNext());
}
}
else {
this.getNext().remove(element);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment