/**
* 节点实体
* @author admin
*
*/
public static class Node{
//当前节点中的数据
public int value;
//下一个节点信息
public Node next;
public static Node createNode(int value){
Node head = new Node();
head.value=value;
head.next=null;
return head;
}
}
/***
* 测试
* @param args
*/
public static void main(String[] args) {
Node head = Node.createNode(0);// 创建第一个节点
Node tail = head;// 默认第一个节点为尾节点
for (int i = 1; i < 10; i++) {
Node tmp = Node.createNode(i * 10);
tail.next = tmp;// 将下一个节点的信息,保存到上一个节点当中
tail = tmp;//给尾节点重新赋值
}
//开始遍历数据
Node nowNode = head;
int index = 0;
while (null != nowNode) {
index++;
System.out.println("第"+index + "个 ,Node =" + nowNode.value);
nowNode = nowNode.next;
}
System.out.println("Node size : " + index);
}
总结一下特点:1.存 : 每个节点,都会存储下一个节点的信息
2.取:无法直接获取某个节点的数据