| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/flchua/StackAnnotation/master/src/stack/MyStringStack.java | [Back] [Original] |
A MyStringStack
* is a class that implements a simple (LIFO) stack object. It makes use of the Vector {@link java.util.Vector} *It has four basic operations:
* push() to push an element onto the stack
* pop() to retrieve the last pushed element
* isEmpty() to verify whether the stack has no more elements
* clear() to empty the stack.
*
This method always returns a valid String.
*If there is no element it throws a NoSuchElementException exception.
* * @return the String on top of the stack * @throws NoSuchElementException if there are no elements on the stack * @see String */ public String pop() throws NoSuchElementException { //throw new NoSuchElementException(); String result = v.lastElement(); v.remove(result); System.out.println("hello"); return result; //return v.lastElement(); } public boolean isEmpty() { return v.isEmpty(); } public void clear() { v = new Vector (); } }| Web Proxy Viewer | New URL | Original Page |