Stack class methods in Java

java.util.Stack

The Stack class represents a last-in-first-out(LIFO) stack of objects. It extends class Vector with five operations that allow a vector to be treated as a stack.


Some methods of  Stack class


empty()This method tests if this stack is empty.


peek()This method looks at the object at the top of this stack without removing it from the stack.


pop()This method removes the object at the top of this stack and returns that object as the value of this function.


push(K)This method pushes an item onto the top of this stack.


search(Object)This method returns the 1-based position where an object is on this stack.


No comments:

Post a Comment