码迷,mamicode.com
首页 > 编程语言 > 详细

java实现的stack数据结构

时间:2014-10-30 22:48:35      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:stack

package com.hephec.ds;
public class SequenceStack {

public  String[] stack; //字符串栈
public int top; //栈顶指针
public final int MAXSIZE=20; //初始化大小

public SequenceStack(){
stack=new String[MAXSIZE];
int top=-1;


public void push(String str){
if(top==MAXSIZE-1){
System.out.println("栈满!");
}
else{
stack[++top]=str;
}
}
public String pop(){
if(top>=0){
return stack[top--];
}else{
return null;
}
}

}

java实现的stack数据结构

标签:stack

原文地址:http://blog.csdn.net/hephec/article/details/40625289

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!