public class ArrayStack{
private String[] items; //数组
private int count; //栈内元素
private int n; //栈大小
//初始化
public ArrayStack(int n){
this.items = new String[n];
this.n = n;
this.count = 0;
}
//入栈
public boolean push(String item){
if(n==count) return false;
items[count] = item;
count++;
return true;
}
//出栈
public String pop(){
if(count == 0) return null;
String tmp = items[count-1];
count--;
return tmp;
}
}
-------------------------------------------------------------------------
## 极客时间全网最便宜最优惠购买方式,优惠券返现 百度网盘 微信关注公众号“选门好课”
扫描下方二维码关注我的公众号"选门好课",与我一起交流知识