nn970510
2016-10-07 15:09
采纳率: 100%
浏览 944
已采纳

Java菜鸟问题,求大神们耐心解答

第一次在CDSN上提问,不知道有没有大神可以帮我看看:
这是我们这个星期的作业要求:
The Sorted List ADT
Implement the SortedList class. The SortedList class extends
the List class. Both can be seen here. Your assignment is to
implement (recursively) all of the abstract methods of the List class.
They are:
insert (recursive)
iterator
remove (recursive)
retrieve (recursive)
search (recursive)
You must also implement an Iterator inner class for the
SortedList class. You must submit a modified SortedList.java
file with your source code. Do not submit and do not modify
the List.java file.

然后我试着写了把retrieve,search和iterator方法都写出来了,唯有insert和remove(我想这两个应该差不多)写不出来,这是我试的代码,被报错,求大神们指点
public void insert(E data){
insert(head, data);

private insert(Node curr, data){
Node temp = new Node (data);
if (curr==null || data.compareTo(curr.data)<0){
temp.next=curr;
curr=temp;
break;
}
else{
continue;
}

return insert(curr.next, data);
}
return;
}

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

7条回答 默认 最新

相关推荐 更多相似问题