-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathStackRunner.java
More file actions
45 lines (32 loc) Β· 844 Bytes
/
Copy pathStackRunner.java
File metadata and controls
45 lines (32 loc) Β· 844 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
package day9;
public class StackRunner {
public static void main(String[] args) {
MyStack stack = new MyStack();
// empty
stack.push(9);
// 9
stack.push(11);
// 9 11
stack.push(-45);
// 9 11 -45
System.out.println(stack.size());
// 3
System.out.println(stack.peek());
// -45
System.out.println(stack.pop());
// -45
System.out.println(stack.size());
// 2
System.out.println(stack.pop());
// 11
System.out.println(stack.size());
// 1
System.out.println(stack.pop());
System.out.println(stack.pop());
System.out.println(stack.peek());
for (int i = 0 ; i < 20 ; i++) {
stack.push(i);
}
stack.push(100);
}
}