Skip to content

Instantly share code, notes, and snippets.

@kanrourou
Last active January 2, 2016 21:38
Show Gist options
  • Save kanrourou/8364323 to your computer and use it in GitHub Desktop.
Save kanrourou/8364323 to your computer and use it in GitHub Desktop.
public class LinkedListStackOfStrings{
private class Node{
private String item;
private Node next;
}
private Node first=null;
public boolean isEmpty(){
if(first==null)
return true;
else
return false;
}
public void push(String s){
Node oldfirst=first;
first=new Node();
first.item=s;
first.next=oldfirst;
}
public String pop(){
if(!isEmpty()){
String s=first.item;
first=first.next;
return s;
}
else
return "Stack is empty!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment