GitHub - BaseMax/MyStackJava: My Stack Implementation In Java. Here we are going to design a full-featured class for Stack's Data structure.
Repository navigation
MyStackJavaPublic
About
My Stack Implementation In Java. Here we are going to design a full-featured class for Stack's Data structure.
Topics
data-structure data-structure-and-algorithm data-structure-java data-structures data-structures-algorithms data-structures-and-algorithms data-structures-interview-questions data-structures-java java stackResources
Readme GPL-3.0 license ActivityStars
1 starWatchers
1 watchingForks
0 forks Report repositoryBranches
Tags
Go to Branches page Go to Tags page
Latest commit
History
9 Commits
View commit history for this file.
Folders and files
| Name | Name | Last commit message | Last commit date |
|---|---|---|---|
| LICENSE | LICENSE | ||
| MyStack.java | MyStack.java | ||
| README.md | README.md | ||
Repository files navigation
MyStack.Java
My Stack Implementation In Java
Here we are going to design a full-featured class for Stack's Data structure.
MyStackJava Functions
public MyStack(int size): Create a new stack with a given sizepublic boolean push(int value): Push an element to the top of the stack and return true.public int pop(): Pop an element from the top of the stack and return the value.public int peek(): Peek the top value of the stack and return the value.public boolean isEmpty(): Return true if the stack is empty.public boolean isFull(): Return true if the stack is full.public int size(): Return the size of the stack.public boolean resize(int newSize): Resize the stack to a new size.public void printStack(): Print the stack.
Using MyStackJava
public class HelloWorld {
public static void main(String []args){
System.out.println("Hello, World!");
MyStack stack = new MyStack(5);
stack.push(1);
stack.push(2);
stack.push(3);
stack.push(4);
stack.push(5);
stack.printStack();
System.out.println("Peek: " + stack.peek());
System.out.println("Pop: " + stack.pop());
System.out.println("Peek: " + stack.peek());
stack.printStack();
}
}
About
My Stack Implementation In Java. Here we are going to design a full-featured class for Stack's Data structure.