1 public class ArrayStack
2 {
3 private Object[] stack;
4
5 private int top = -1;
6
7 public ArrayStack(int size)
8 {
9 stack = new Object[size];
10 }
11
12 public boolean add(Object data)
13 {
14 if(isFull() == true)
15 {
16 return false;
17 }
18
19 stack[++ top] = data;
20
21 return true;
22 }
23
24 public Object get()
25 {
26 if(isEmpty() == true)
27 {
28 return null;
29 }
30 else
31 {
32 return stack[top --];
33 }
34 }
35
36 public boolean isEmpty()
37 {
38 if(top == -1)
39 {
40 return true;
41 }
42 else
43 {
44 return false;
45 }
46 }
47
48 public boolean isFull()
49 {
50 if(top == stack.length - 1)
51 {
52 return true;
53 }
54 else
55 {
56 return false;
57 }
58 }
59
60 }