class Test
{
public static void sop(Object obj){
System.out.println(obj);
}
public static void main(String[] args)
{
MyStack st=new MyStack();
st.push("asdasd1");
st.push("asdasd2");
st.push("asdasd3");
st.push("asdasd4");
while(!st.isE()){
sop(st.pop());
}
}
}
class MyStack
{
private LinkedList ll =null;
public MyStack(){
ll=new LinkedList();
//System.out.println("gouzao ");
}
public void push(Object obj){
ll.addFirst(obj);
//System.out.println(ll.isEmpty());
//System.out.println(obj);
}
public Object pop(){
return ll.removeFirst();
}
public boolean isE()
{
//System.out.println(ll.isEmpty());
return ll.isEmpty();
}
}
|
|