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!