一种线性的存储结构,实现先进后出的原则,用链表实现的时候只能从头节点开始才能实现完整的铺上,pop,peap的完整操作,不同于数组的实现,链表不需要判断栈不否满了,只需要判断是否为空。

入栈:在头指针后面插入数据;

出栈:把头指针后一位的数据输出;

链表的定义

package com.jiedada.jiegou;

public class Node1 {
    private Object data;
    private Node1 next;
    public Node1() {
        this.data=null;
        this.next=null;
    }
    public Node1(Object data) {
        this.data=data;
        this.next=null;
    }
    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }
    public Node1 getNext() {
        return next;
    }
    public void setNext(Node1 next) {
        this.next = next;
    }
    

}
View Code

相关文章:

  • 2021-12-11
  • 2021-06-10
  • 2021-09-23
  • 2021-07-09
  • 2022-03-03
  • 2021-07-06
  • 2021-12-22
  • 2021-05-06
猜你喜欢
  • 2021-11-09
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案