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:
|
public class Stack<T> {
private int size;
private Entry<T> this.head;
public Stack (){
this.head=null;
}
public int size() {
return this.size;
}
public void push(T Element){
Entry<T> current=new Entry<T>(Element, this.head);
this.head=current;
this.size++;
}
public T pop(){
if(this.head==null){
throw new NullPointerException("Liste leer");
}
Entry<T> current=this.head;
this.head=this.head.getnext();
this.size--;
return current.getelement;
}
|