-
Notifications
You must be signed in to change notification settings - Fork 28
/
StackArrayDemo.java
50 lines (37 loc) · 1.38 KB
/
StackArrayDemo.java
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
package ds_004_stacks_and_queues;
public class StackArrayDemo {
public static void main(String[] args) {
StackArray<Integer> stack = new StackArray<>(1);
System.out.println("Stack is EMPTY: " + stack.isEmpty());
stack.push(10);
System.out.println("Stack is EMPTY: " + stack.isEmpty());
stack.print();
Integer popped = stack.pop();
System.out.println("Popped: " + popped);
System.out.println("Stack is EMPTY: " + stack.isEmpty());
System.out.println("\tCAPACITY: " + stack.capacity());
stack.push(10);
System.out.println("\tCAPACITY: " + stack.capacity());
stack.push(20);
System.out.println("\tCAPACITY: " + stack.capacity());
stack.push(30);
System.out.println("\tCAPACITY: " + stack.capacity());
stack.push(40);
System.out.println("\tCAPACITY: " + stack.capacity());
stack.push(50);
System.out.println("\tCAPACITY: " + stack.capacity());
System.out.println("\tCAPACITY: " + stack.capacity());
stack.pop();
System.out.println("\tCAPACITY: " + stack.capacity());
stack.pop();
System.out.println("\tCAPACITY: " + stack.capacity());
stack.pop();
System.out.println("\tCAPACITY: " + stack.capacity());
stack.pop();
System.out.println("\tCAPACITY: " + stack.capacity());
stack.pop();
System.out.println("\tCAPACITY: " + stack.capacity());
System.out.println("Stack is EMPTY: " + stack.isEmpty());
stack.print();
}
}