16.8 Stack Class of Package java.util

We introduced the concept of a stack in Section 6.6 when we discussed the method-call stack. In Chapter 21, Custom Generic Data Structures, we’ll learn how to build data structures, including linked lists, stacks, queues and trees. In a world of software reuse, rather than building data structures as we need them, we can often take advantage of existing data structures. In this section, we investigate class Stack in the Java utilities package (java.util).

Class Stack extends class Vector to implement a stack data structure. Figure 16.14 demonstrates several Stack methods. For the details of class Stack, visit http://docs.oracle.com/javase/7/docs/api/java/util/Stack.html.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.