package suanfa; public class MylinkStack<T> implements Mystack<T> { private Node1 top=null; int size=0; @Override public boolean isempty() { // TODO Auto-generated method stub return size==0; } @Override public void clear() { // TODO Auto-generated method stub top=null; size=0; } @Override public int length() { // TODO Auto-generated method stub return size; } @Override public boolean push(T data) { // TODO Auto-generated method stub Node1 newnode=new Node1(); newnode.data=data; newnode.prev=top; top=newnode; size++; return true; } @Override public T pop() { // TODO Auto-generated method stub if(top==null){ return null; } Node1 node=top; top=top.prev; size--; return (T)node.data; } public class Node1{ Node1 prev; T data; } }