【发布时间】:2020-11-20 18:53:28
【问题描述】:
你好,我有一个界面;
public interface List<Type> {
void addAll(List<Type> list);
int addAll(int index, List<Type> list);
}
如您所见,实现清晰;
public class DoublyLinkedList<Type> implements List<Type> {
@Override
public void addAll(List<Type> list) {
Node<Type> old = first(); //returns old linked list.Also I can call the tail node with
// tail variable.
}
@Override
public int addAll(int index, List<Type> list) {
// TODO Auto-generated method stub
return 0;
}
}
并且有一个构造函数类;
public class Node<Type> {
protected Type data;
protected Node<Type> next;
protected Node<Type> previous;
public Node(Type data, Node<Type> next,Node<Type> previous) {
this.data = data;
this.next = next;
this.previous = previous;
}
public Type getData() {
return data;
}
public Node<Type> getNext() {
return next;
}
public Node<Type> getPrevious() {
return previous;
}
}
我没有把我所有的方法都放在上面。由于我的项目,我的问题是如何实现这些方法?我想通过界面在旧链表之后添加一个新链表。
【问题讨论】:
标签: java data-structures generic-list