forked from Ameesha15/DSA-ALGORITHMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntStack.java
More file actions
36 lines (34 loc) · 705 Bytes
/
Copy pathIntStack.java
File metadata and controls
36 lines (34 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class IntStack {
private int [] stack;
private int top;
private int size;
public IntStack(){
top = -1;
size = 50;
stack = new int[50];
}
public IntStack(int size){
top = -1;
this.size = size;
stack = new int[this.size];
}
public boolean push(int value){
if(!isFull()){
top++;
stack[top]=value;
return true;
}
else{
return false;
}
}
public int pop(){
return stack[top--];
}
public boolean isEmpty(){
return (top == -1);
}
public boolean isFull(){
return(top==stack.length - 1);
}
}