我需要使用递归从链表中删除一个节点。这是我到目前为止的代码...如何使用递归从链表中删除节点?
public class SortedSetNode implements Set {
protected String value;
protected SortedSetNode next;
public boolean remove(String element) {
if (value.equals(element))
{
next = next.getNext();
return true;
}
else
{
return next.remove(element);
}
}
如果我将其更改为此,该怎么办? 'if(next.value.equals(element))' – lauraxx
您是试图从头编写自己的数据结构,还是想实现java.util.Set接口?无论如何,看看那些现有的实现将会有所帮助。 –