Package COM. handy. DS; public class simplestack {// Stack Array private int [] arrays; // stack capacity private int capacity; // Number of stack elements Private int size; // automatically increase the size private int autosize = 5; Public simplestack (INT capacity) {size = 0; this. capacity = capacity; arrays = new int [capacity];}/*** @ return the arrays */Public int [] getarrays () {return arrays ;} /*** @ Param arrays * The arrays to set */Public void setarrays (INT [] arrays) {T His. arrays = arrays;}/*** @ return the capacity */Public int getcapacity () {return capacity ;} /*** @ Param capacity * the capacity to set */Public void setcapacity (INT capacity) {This. capacity = capacity;}/*** @ return the size */Public int getsize () {return size ;} /*** @ Param size * the size to set */Public void setsize (INT size) {This. size = size;} // The growth function public void extend (INT increment) {int [] Ex Tendstack = new int [capacity + increment]; capacity = capacity + increment; For (INT I = 0; I <size; I ++) extendstack [I] = arrays [I]; arrays = extendstack;} // returns the top element of the stack and changes the stack state to public int POP () {If (isempty () = true) Return-1; elsereturn arrays [-- size];} // public void push (INT number) {If (isfull () = true) {system. out. println ("the stack is full! "); // Capacity = capacity + autosize; // arrays = new int [capacity]; Extend (autosize); system. Out. println (" automatic growth! "+" Size: "+ autosize); arrays [size ++] = number;} elsearrays [size ++] = number ;} // determine whether the stack is empty public Boolean isempty () {If (size = 0) return true; elsereturn false;} // determine whether the stack is full public Boolean isfull () {If (size = capacity) return true; elsereturn false;} // gets the top element of the stack, but does not change the stack state public int stacktop () {If (isempty () = false) return arrays [size-1]; elsereturn-1 ;}}