Repository navigation
MyStackJava
Public
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 stack
Resources
Readme
GPL-3.0 license
Activity
Stars
1 star
Watchers
1 watching
Forks
0 forks
Report repository
Branches
Tags
Go to Branches page Go to Tags page
Latest commit
History
9 Commits
View commit history for this file.
Folders and files
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 size
public 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.
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 stack
Resources
Readme
GPL-3.0 license
Activity
Stars
1 star
Watchers
1 watching
Forks
0 forks
Report repository
Releases
Packages
Used by
Contributors
Languages