求用java写的链表数据结构

解决方案 »

  1.   

    看数据结构(java语言描述)方面的书
      

  2.   

    恩,自己实现。用java写一个。
      

  3.   

    弄个简单的。链表大概就这样
    class LinkList{
    private LinkNode first;//This field is used to reference to first link on list
    public LinkList(){//The coustructor of Linklist class
    first=null;//This Statement indicate that there is no items on list yet
    }
    public boolean isEmpty(){
    return(first==null);
    }
    public void insertFirst(double dd){
    LinkNode newLink=new LinkNode(dd);
    newLink.next=first;
    first=newLink;
    }
    public LinkNode deleteFirst(){
    LinkNode temp=first;
    first=first.next;
    return temp;
    }
    public void displayList(){
    LinkNode current=first;
    while(current!=null){
    current.displayLinkNode();
    current=current.next;
    }
    }
    }
    class LinkNode{
    private double dDate;//The data of the LinkList;
    public LinkNode next;
    public LinkNode(double dd){
    this.dDate=dd;
    }
    public void displayLinkNode(){
    System.out.println("The Date of this NOde is:"+this.dDate);
    }
    }
    public class Test{
    public static void main(String[] args){
    LinkList theList=new LinkList();
    theList.insertFirst(22.22);
    theList.insertFirst(33.33);
    theList.displayList();
    System.out.println("is Empty or not:"+theList.isEmpty());
    theList.deleteFirst();
    System.out.println("After we delete the first Node:");
    theList.displayList();
    theList.insertFirst(44.44);
    System.out.println("After we insert the first Node:");
    theList.displayList();
    }
    }