A Java implementation of stack using Linked List. It uses Linked List which can be found here.
package lab.stack;
import lab.linkedlist.*;
public class Stack
{
LinkedList stackList;
public Stack()
{
stackList=new LinkedList();
stackList.headnode=null;
}
public void push(Object data)
{
stackList.insertBegining(data);
}
public Object pop()
{
return stackList.getFirstinList();
}
}
package lab.stack;
import lab.linkedlist.*;
public class Stack
{
LinkedList stackList;
public Stack()
{
stackList=new LinkedList();
stackList.headnode=null;
}
public void push(Object data)
{
stackList.insertBegining(data);
}
public Object pop()
{
return stackList.getFirstinList();
}
}
No comments:
Post a Comment