Hi
I want to know that how can I copy my objects from an arrayList to a doubly linked list?
also my DNode constructor is :
public DNode(Object element, DNode prev, DNode next) {
this.element = element;
this.next = next;
this.prev = prev;
}
i.e. when I write such a code my program doesn’t work :
DNode node = new DNode(pointList.get(0),null, null);
for (int i = 1; i < pointList.size(); i++) {
DNode dNode = new DNode(pointList.get(i), node, null);
dList.addLast(dNode);
}
also i have written doubly linked list which has addAfter and addBefore methods and also much more.
java.util.LinkedListis a doubly-linked list.You can create it by passing the array list as constructor argument:
Update: The
java.util.LinkedListhasadd(index, element)which, combined withindexOf(..)should cover theaddBeforeandaddAftermethods. You can extendLinkedListto add these convenient methods if you like.