.net

.net

 

单链表

 1 package com.comm;
 2 
 3 
 4 
 5 public class LinkList {
 6     public class Node{
 7         public int data;
 8         public Node next;
 9         public Node(int data){
10             this.data=data;
11         }
12     }
13     
14     public Node head=null;
15     
16     public void add(int data){
17         if (head==null){
18             head=new Node(data);
19         }else{
20             add(head,data);
21         }
22     }
23     
24     public void add(Node node,int data){
25         
26         if (node.next==null){
27             node.next=new Node(data);
28             return;
29         }
30         add(node.next,data);        
31     }
32 
33 }
View Code

 

posted on 2014-10-18 11:50  严杰  阅读(103)  评论(0编辑  收藏  举报

导航