-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstack
More file actions
50 lines (46 loc) · 1.05 KB
/
stack
File metadata and controls
50 lines (46 loc) · 1.05 KB
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
49
50
class stack{
int a[]=new int[10];
int st_top;
stack(){
st_top=-1;
}
void push(int num){
if(st_top==9) System.out.println("stack full");
else a[++st_top]=num;
}
int pop(){
if(st_top<0){
System.out.println("stack is empty");
return 0;
}
else return a[st_top--];
}
protected void finalize() {
System.out.println("this is finalize");
for(int i=0;i<10;i++) System.out.println(a[i]);
}
void print(){
System.out.println("this is print function.. ");
for(int i=0;i<10;i++) System.out.println(a[i]);
}
}
public class testcomma {
public static void main(String args[]){
stack s=new stack();
s.push(5);
s.pop();
s.push(25);
s.push(54);
s.push(15);
s.pop();
s.push(95);
s.push(45);
s.push(55);
s.push(1125);
s.push(19);
s.push(10);
s.print();
s=null;
System.gc();
}
}