home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Java Fundamental Classes Reference

Previous Chapter 5
Collections
Next
 

5.3 Stacks

The Stack class is a subclass of Vector that implements a last-in-first-out (LIFO) object stack. The Stack class uses the following methods to provide stack behavior:

  • The push() method pushes an object onto the top of the stack.

  • The pop() method removes and returns the top element from the stack. If the stack is empty, pop() throws an EmptyStackException.

  • The peek() method returns, but does not remove, the top element from the stack. If the stack is empty, peek() throws an EmptyStackException.

  • The empty() method returns true if and only if the stack is empty.


Previous Home Next
Vectors Book Index Hashtables

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java