-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplateDemo.java
More file actions
38 lines (30 loc) · 761 Bytes
/
TemplateDemo.java
File metadata and controls
38 lines (30 loc) · 761 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
package Codes;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
class Stack<T extends Serializable, T2> {
ArrayList<T> data = new ArrayList<>();;
Map<T, T2> map = new HashMap<>();
void push(T value, T2 value2) {
data.add(value);
map.put(value, value2);
}
void peep() {
System.out.println("Map is " + map);
for (int i = data.size() - 1; i >= 0; i--) {
System.out.println(data.get(i));
}
}
}
public class TemplateDemo {
public static void main(String[] args) {
Stack<String, Double> stack1 = new Stack<>();
stack1.push("hello", 90.20);
// Stack<String> stack2 = new Stack<String>();
// stack.push(10);
// stack.push(20);
// stack.push("Hello");
stack1.peep();
}
}