It is great! I pass through it by myself.
public static <T> void removeDuplicates(SinglyLinkedList<T> list) {
if (list.isEmpty()) return;
SinglyLinkedList<T>.Node node = list.getHeadNode();
SinglyLinkedList<T>.Node current = null;
SinglyLinkedList<T>.Node prev = null;
while (node != null)
{
current = node.nextNode;
prev = node;
while (current != null)
{
if (current.data.equals(node.data))
{
prev.nextNode = current.nextNode;
}
else
{
prev = prev.nextNode;
}
current = current.nextNode;
}
node = node.nextNode;
}
}