程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> LinkedList implement

LinkedList implement

編輯:C++入門知識

public class LinkedList {


Node head = null;
Node tail = null;

int length = 0;

public void add(Object object) {
Node node = new Node(object, null);
if (head == null) {
head = tail = node;
}

tail.setNext(node);
tail = node;
length++;
}

public int length() {
return length;
}

}

 

public class Node {


private Object data;
private Node next;


public Node(Object data, Node next) {
super();
this.data = data;
this.next = next;
}

public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public Node getNext() {
return next;
}
public void setNext(Node next) {
this.next = next;
}


}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved