Java链栈
来源:互联网 发布:进销存软件免费版 编辑:程序博客网 时间:2024/06/04 18:22
package com.lxm.customDataStructure;public class LinkStack<T>{ class Node<T>{ T data; Node next; Node(T data) { this.data=data; this.next = null; } } Node<T> head; public LinkStack(T data) { this.head = null; } public boolean isEmpty() { return this.head==null; } public void push(T e) { Node temp = new Node(e); temp.next = this.head; this.head = temp; } public T pop() { if(this.isEmpty()) return null; Node temp = this.head; this.head = temp.next; return (T) temp.data; } public static void main(String[] args) { LinkStack<Integer> S = new LinkStack<Integer>(0); for(int i=0;i<10;i++) { S.push(i+1); } while(S.isEmpty()==false) { System.out.print(S.pop()+"\t"); } System.out.println(); }}
0 0
- Java链栈
- (5)链栈(Java)
- 链栈(java实现)
- 数据结构 -- 链栈java实现
- java
- JAVA
- JAVA
- JAVA
- java
- Java
- Java
- JAVA:
- java
- java
- java
- java
- Java
- java
- RISC诞生与发展的缩影
- 获取缓存大小和清除缓存功能
- AndroidStudio设置三步走
- Android--多媒体
- UVA - 133 The Dole Queue
- Java链栈
- 2016.07.08【初中部 NOIP提高组 】模拟赛C
- scrollview滑动跟侧滑的冲突
- 如何实现 Android 应用的持续部署?
- Linux下安装jdk
- 一步一图一代码,一定要让你真正彻底明白红黑树 (July算法!!!)
- UVA - 10152 ShellSort
- Codeforces New Year and Days
- 1061. Dating (20)-PAT甲级真题