学习java,挺好玩的呢

 

 

 

 1 public class DoubleNode {
 2     //上一个节点
 3     DoubleNode pre=this;
 4     //下一个节点
 5     DoubleNode next=this;
 6     //节点数据
 7     int data;
 8     
 9     public DoubleNode(int data){
10         this.data=data;
11     }
12     
13     //增节点
14     public void after(DoubleNode node){
15         //原来的下一个节点
16         DoubleNode nextNext=next;
17         //把新节点作为当前节点的下一个节点
18         this.next=node;
19         //把当前节点的下一个节点设为新节点
20         node.pre=this;
21         //让原来的下一个节点设为新节点的下一个节点
22         node.next=nextNext;
23         //让原来的下一个节点的上一个节点为新节点
24         nextNext.pre=node;
25     }
26     
27     //下一个节点
28     public DoubleNode next(){
29         return this.next;
30     }
31     //上一个节点
32     public DoubleNode pre(){
33         return this.pre;
34     }
35     //获取数据
36     public int getData(){
37         return this.data;
38     }
39     
40 }

 

posted on 2018-11-16 13:51  axu521  阅读(133)  评论(0编辑  收藏  举报

<