Java: Stack (LIFO: Last In First Out)

Publicado em: 13 Janeiro 2024
no canal de: HowTo:
815
3

Introduction to Stack in Java.
A stack is a collection of objects that are inserted and removed in a LIFO(Last In First Out) fashion. So, when we need a plate, we take (pop) from the top of the stack, and when we want to add a plate, we put (push) it at the top as well. We cannot add or remove a plate at the middle of the stack.

We can perform various operations on stack other than push() and pop(). We can see the topmost element in the stack using peek(); we can know the size of the stack using the size() method. Also we can check if the stack is empty using the empty() method.

The Java collections framework has a Stack Class that provides the functionality of the Stack Data structure. The Stack class extends the Vector class.

LIFO or FILO? :)

00:05 - info
00:16 - Initialize the stack
00:37 - .empty()
00:53 - .push(e)
01:25 - .size()
01:39 - .peek()
02:00 - .pop()

#howto #java #easyway #firststep #stack #lifo #filo

Music track: Too Hot by Aylex
Source: https://freetouse.com/music
Free Background Music for Video


Nesta página do site você pode assistir ao vídeo on-line Java: Stack (LIFO: Last In First Out) duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário HowTo: 13 Janeiro 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 815 vezes e gostou 3 espectadores. Boa visualização!