链表内容参考上一篇文章代码。
package test2;
public class LinkStack {
private LinkList list;
public LinkStack(){
list = new LinkList();
}
public void push(int iData, double dData){
list.insertFront(iData, dData);
System.out.println("push sucess:"+iData+"--"+dData);
}
public void pop(){
LinkNode temp = list.deleteFirstNode();
if(temp == null){
System.out.println("object is null");
}else{
System.out.println("pop sucess:");
temp.displayLink();
System.out.println("------");
}
}
public boolean isEmpty(){
return list.isEmpty();
}
public void displayLinkStack(){
list.displayLinkList();
}
}
class TestLinkStack{
public static void main(String args[]){
LinkStack linkStack = new LinkStack();
linkStack.push(1, 1d);
linkStack.push(2, 2);
linkStack.push(3, 3);
linkStack.displayLinkStack();
linkStack.pop();
linkStack.displayLinkStack