stacks and queues stack example reversing word for our first example of using stackwe'll examine very simple taskreversing word when you run the programit asks you to type in word when you press enterit displays the word with the letters in reverse order stack is used to reverse the letters firstthe characters are extracted one by one from the input string and pushed onto the stack then they're popped off the stack and displayed because of its last-in-first-out characteristicthe stack reverses the order of the characters listing shows the code for the reverse java program listing the reverse java program /reverse java /stack used to reverse string /to run this programc>java reverseapp import java io */for / ///////////////////////////////////////////////////////////////class stackx private int maxsizeprivate char[stackarrayprivate int top//public stackx(int max/constructor maxsize maxstackarray new char[maxsize]top - //public void push(char /put item on top of stack stackarray[++topj//public char pop(/take item from top of stack return stackarray[top--]//public char peek(/peek at top of stack return stackarray[top]