-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrStack.java
More file actions
48 lines (39 loc) · 718 Bytes
/
Copy patharrStack.java
File metadata and controls
48 lines (39 loc) · 718 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
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.*;
import java.io.*;
import java.lang.*;
class arrStack
{
int max = 100;
int arr[] = new int[max];
int top;
arrStack()
{
top = -1;
}
void push (int ele)
{
if(top == arr.length)
System.out.println("Stack full");
else
arr[++top] = ele;
}
int pop()
{
if(top==-1)
{
System.out.println("Stack empty");
return -1;
}
else
return arr[top--];
}
public static void main (String[] args)
{
arrStack obj = new arrStack();
obj.push(5);
obj.push(10);
obj.pop();
obj.pop();
obj.pop();
}
}