This repository contains the implementation of a Stack Data Structure using arrays in Java.
A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. This means the last element inserted into the stack will be the first one to be removed.
The following operations can be performed on a stack:
isEmpty()– Checks if the stack is empty.isFull()– Checks if the stack is full.push()– Inserts an element onto the stack.pop()– Removes the top element from the stack.peek()– Returns the top element without removing it.
This project contains two files:
-
Stack.java
- Implements the stack using an array.
- Contains all the stack operations mentioned above.
-
StackDemo.java
- Demonstrates the usage of the
Stackclass. - Performs different stack operations.
- Demonstrates the usage of the
- Clone the repository.
- Compile the Java files:
javac Stack.java StackDemo.java