Last active
June 22, 2017 03:33
-
-
Save gabrielfern/9744c43bd4a068f565af4c8a65f4bc98 to your computer and use it in GitHub Desktop.
remove - recursive linked list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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