package test; public class MyStack { private String[] elements; private int nextIndex; public MyStack() { elements = new String[100]; nextIndex = 0; } public void push(String element) throws Exception { if(100 == nextIndex) { throw new Exception("数组越…