forked from rbk-org/Java_DataStructures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.java
More file actions
31 lines (26 loc) · 644 Bytes
/
Copy pathStack.java
File metadata and controls
31 lines (26 loc) · 644 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
import java.util.Arrays;
public class Stack {
public int[] arr =new int[3];
public int counter =0;
//your code is here
public void push(int pushedElement){
//your code is here
if(counter>=3){
//arr=Arrays.copyOf(arr,counter*2);
System.out.println("overflow condition");
}
arr[counter]=pushedElement;
counter++;
}
public void pop() {
//your code is here
if(counter>0){
counter--;
System.out.println(arr[counter]);
}
else
System.out.println("underflow condition");
}
public static void main(String[] args) {
}
}