1、
package java.util;
public class Node2Test
{
public static void main(String[] args)
{
Node2 node1 = new Node2("node1");
Node2 node2 = new Node2("node2");
Node2 node3 = new Node2("node3");
node1.next = node2;
node2.previous = node1;
node2.next = node3;
node3.previous = node2;
node3.next = node1;
node1.previous = node3;
System.out.println("-------------");
Node2 node4 = new Node2("node4");
node1.next = node4;
node4.previous = node1;
node4.next = node2;
node2.previous = node4;
System.out.println("-------------");
node1.next = node2;
node2.previous = node1;
node4.next = null;
node4.previous = null;
}
}
2、关于ArrayList与LinkedList 比较分析
a) ArrayList底层采用数组实现,LinkedList底层采用双向链表实现
b)当执行插入或删除操作时,采用LinkedList比较好
c)当执行搜索操作时,采用ArrayList比较好