1 import java
.util
.ArrayDeque
;
2 import java
.util
.NoSuchElementException
;
8 * @param String[] args main() function arguments array
10 public static void main(String
[] args
) {
11 Pile
<Integer
> stack
= new Pile
<Integer
>(5);
21 System
.out
.println("Stack index " + stack
.getHeadIndex());
22 System
.out
.println("Stack head value " + stack
.depiler());
23 System
.out
.println("Stack index " + stack
.getHeadIndex());
24 System
.out
.println("Stack head value " + stack
.depiler());
25 System
.out
.println("Stack index " + stack
.getHeadIndex());
26 System
.out
.println("Stack head value " + stack
.depiler());
27 System
.out
.println("Stack index " + stack
.getHeadIndex());
28 System
.out
.println("Stack head value " + stack
.depiler());
29 System
.out
.println("Stack index " + stack
.getHeadIndex());
30 System
.out
.println("Stack head value " + stack
.depiler());
31 System
.out
.println("Stack index " + stack
.getHeadIndex());
32 System
.out
.println("Stack head value " + stack
.depiler());
33 System
.out
.println("Stack index " + stack
.getHeadIndex());
37 Pile
<String
> stackStr
= new Pile
<String
>(5);
39 stackStr
.empiler("Bonjour");
40 stackStr
.empiler("Salut");
41 stackStr
.empiler("Hello");
42 stackStr
.empiler("Hi");
43 stackStr
.empiler("Hugh");
47 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
48 System
.out
.println("Stack head value " + stackStr
.depiler());
49 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
50 System
.out
.println("Stack head value " + stackStr
.depiler());
51 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
52 System
.out
.println("Stack head value " + stackStr
.depiler());
53 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
54 System
.out
.println("Stack head value " + stackStr
.depiler());
55 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
56 System
.out
.println("Stack head value " + stackStr
.depiler());
57 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
58 System
.out
.println("Stack head value " + stackStr
.depiler());
59 System
.out
.println("Stack index " + stackStr
.getHeadIndex());
63 ArrayDeque
<String
> stackStrDeq
= new ArrayDeque
<String
>();
64 stackStrDeq
.push("Bonjour");
65 stackStrDeq
.push("Salut");
66 stackStrDeq
.push("Hello");
67 stackStrDeq
.push("Hi");
68 stackStrDeq
.push("Hugh");
71 System
.out
.println("Stack index " + stackStrDeq
.size());
72 System
.out
.println("Stack head value " + stackStrDeq
.pop());
73 System
.out
.println("Stack index " + stackStrDeq
.size());
74 System
.out
.println("Stack head value " + stackStrDeq
.pop());
75 System
.out
.println("Stack index " + stackStrDeq
.size());
76 System
.out
.println("Stack head value " + stackStrDeq
.pop());
77 System
.out
.println("Stack index " + stackStrDeq
.size());
78 System
.out
.println("Stack head value " + stackStrDeq
.pop());
79 System
.out
.println("Stack index " + stackStrDeq
.size());
80 System
.out
.println("Stack head value " + stackStrDeq
.pop());
81 System
.out
.println("Stack index " + stackStrDeq
.size());
82 // It will trigger the exception
83 System
.out
.println("Stack head value " + stackStrDeq
.pop());
84 System
.out
.println("Stack index " + stackStrDeq
.size());
86 catch (NoSuchElementException e
) {