we can implement stack by storing its elements in an array specificallythe stack in this implementation consists of an -element array plus an integer variable that gives the the index of the top element in array (see figure figure implementing stack with an array the top element in the stack is stored in the cell [trecalling that arrays start at index in javawe initialize to - and we use this value for to identify an empty stack likewisewe can use to determine the number of elements ( we also introduce new exceptioncalled fullstackexceptionto signal the error that arises if we try to insert new element into full array exception fullstackexception is specific to this implementation and is not defined in the stack adthowever we give the details of the array-based stack implementation in code fragment code fragment array of given sizen implementing stack using an