DEV Community

Cover image for Building a Stack Implementation in Java: Mastering Data Structure Fundamentals.
Sarthak sachdeva
Sarthak sachdeva

Posted on

Building a Stack Implementation in Java: Mastering Data Structure Fundamentals.

*Hey in this code i will make a stack implementation programme *

We have a class "Stack" :
in this class i make a all method for implement stack ,
i using Integer Array to store Stack Data, and in this class we have a some other propertys ,
like : i am define the Stacksize but when i create a object to am define my new stack size , and we have a **indexvalue **of array for where to stack fill data in array and find data and remove

* THIS IS STACK CLASS

Image description

in this class we have a some method like

  1. public void size() -> to store the size of stack;
  2. public void push() -> to push data in stack
  3. public void pop() -> to remove last element of stack array
  4. public void remove() -> to remove stack element but give the indexvalue of element which one you want to remove
  5. public void getStack() -> and get all stack values

Methods implement

Image description

Image description

Image description

Image description

Image description

Image description

NOW MAKE A OBJECT AND MAKE A STACK

Image description

when an create a object to use stack to am define here my stack size 2 so am set only 2 integer data in stack

if you want to code of this stack implementation go to my github repo
github

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay