Skip to content

Commit bb37cd8

Browse files
author
leijing
committed
add
add
1 parent ee6dc8b commit bb37cd8

File tree

1 file changed

+8
-9
lines changed
  • group07/764189149/src/firstHomeWork/util

1 file changed

+8
-9
lines changed
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
package firstHomeWork.util;
22

3-
import java.util.Queue;
4-
5-
public class Stack {
6-
private ArrayList elementData = new ArrayList();
7-
public void push(Object o){
3+
public class Stack<E> {
4+
private ArrayList<E> elementData = new ArrayList<E>();
5+
public void push(E e){
6+
elementData.add(e);
87
}
98

109
public Object pop(){
11-
return null;
10+
return elementData.remove(elementData.size() - 1);
1211
}
1312

1413
public Object peek(){
15-
return null;
14+
return elementData.get(elementData.size() - 1);
1615
}
1716
public boolean isEmpty(){
18-
return false;
17+
return elementData.isEmpty();
1918
}
2019
public int size(){
21-
return -1;
20+
return elementData.size();
2221
}
2322
}

0 commit comments

Comments
 (0)