package link; /** * 测试类,自己看吧。 * @author * 创建时间:2011-4-1 上午10:15:59 * 类说明: */public class NodeListConstructor { public static void main(String[] args){ NodeList list = new NodeList(); list.addNode(new Node(3)); list.addNode(new Node(1)); list.addNode(new Node(2)); list.addNode(new Node(4)); list.addNode(new Node(5)); list.addNode(new Node(6)); list.reversePrint(); } } public void turnList() throws Exception
{
if(head==null)
throw new Exception("null list");
else
if(head==tail)
;
else
{
Node new_head=head;
while(head.next.next!=null)
{
Node temp=head.next;
head.next=temp.next;
temp.next=new_head;
new_head=temp;
}
tail.next=new_head;
Node temp=tail;
tail=head;
tail.next=null;
head=temp;
}
}
上一页 [1] [2]