/Stack Using Linked List

Stack Using Linked List

Stack Using Linked List

package datastructure.algorithms.Stack;

/**
 *
 * @author GOKUL
 */
public class StackUsingLinkedList {
    private Node head;
    
    public StackUsingLinkedList()
    {
        this.head=null;
    }
    
    public void push(int data)
    {
        head=new Node(data,head);
    }
    
    public int pop()
    {
        int data=head.getData();
        head=head.getNext();
        return data;
    }
}