-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomStack.java
More file actions
45 lines (39 loc) · 887 Bytes
/
CustomStack.java
File metadata and controls
45 lines (39 loc) · 887 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
import com.users.Customer;
import java.lang.Integer;
import java.lang.reflect.Array;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.lang.Number;
import java.util.concurrent.*;
public class CustomStack<T>{
private List<T> list;
public CustomStack(){
list = new ArrayList<>();
}
public void push(T a){
list.add(a);
}
public boolean clear(){
list.clear();
return true;
}
public boolean empty(){
return list.isEmpty();
}
public T pop(){
if(empty()){
return null;
}
int len = list.size();
T top = list.get(len - 1);
list.remove(list.lastIndexOf(top));
return top;
}
public int size(){
return list.size();
}
@Override
public String toString(){
return list.toString();
}
}