0% found this document useful (0 votes)
2 views7 pages

Java Stack

The document provides an overview of the Stack data structure in Java, which operates on a LIFO principle. It explains that the Stack class in Java is a legacy class that inherits from Vector and is thread-safe, but suggests using ArrayDeque for better efficiency in single-threaded environments. Additionally, it mentions that stacks can be created for various non-primitive data types such as Integer, Character, and Strings.

Uploaded by

help90780
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Java Stack

The document provides an overview of the Stack data structure in Java, which operates on a LIFO principle. It explains that the Stack class in Java is a legacy class that inherits from Vector and is thread-safe, but suggests using ArrayDeque for better efficiency in single-threaded environments. Additionally, it mentions that stacks can be created for various non-primitive data types such as Integer, Character, and Strings.

Uploaded by

help90780
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

TIPS

Overview of
Java Collections

Stack

JEYSIVA AP
01

What is Stack?
The stack is a linear data structure, the
operations are performed in order LIFO
(Last In First Out) or FILO (First In Last
Out).
02

Stack - Java Collections


The Java Collection framework provides a Stack
class that models and implements a Stack data
structure.

Please note that the Stack class in Java is a


legacy class and inherits from Vector in Java. It
is a thread-safe class and hence involves
overhead. When we do not need thread safety.
It is recommended to use ArrayDeque for stack
implementation as it is more efficient in a
single-threaded environment.
03

Create an Stack

In this case, we have made an stack of type


Integer, but we can make stack for all other
non-primitive data types as well. Examples
include Character, Strings, Long etc.
04
05

Few in-build methods


04

was this post


helpful to you?
Be sure to save it so you
can come back to it later!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy