1
5 class Stack {
6
7 private int[] elements;
9 private int count;
11
14 public Stack(int capacity) {
15 elements = new int[capacity];
16 }
17
18
21 public boolean isempty() {
22 return ( count == 0 ); }
24
25
28 public int size() {
29 return count;
30 }
31
32
35 public boolean offerfirst(int number) {
36
37 if ( count == elements.length ) return false;
39 else {
40 elements[ count++ ] = number; return true;
42 }
43 }
44
45
48 public int pollfirst() {
49
50 if ( count == 0 )
51 return -999999;
52 else
53 return elements[ --count ];
54 }
55
56 }
57