答案是:栈。
使用数组实现一个栈
/** * Created by **** on 2018/10/16. * 基于数组实现的顺序栈 */ public class ArrayStack { private String[] items; private int n; private int count; //数组初始化,申请一个大小为n的空间 public ArrayStack(int n){ this.items = new String[n]; this.n = n; this.count = 0; } //入栈操作 public boolean push(String item){ if(count == n) return false; items[count] = item; ++count; return true; } //出栈操作 public String pop(){ if(count == 0) return null; String temple = items[count]; --count; return temple; } }