package linear;
public class StackUsingLinkedList
private LinkedList
public void push(T v) {
list.addFront(v);
}
public T peek() {
return list.getFront();
}
public T pop() {
return list.deleteFront();
}
public boolean isEmpty() {
return list.isEmpty();
}
public static void main(String[] args) {
StackUsingLinkedList
//stack.pop(); // an exception is triggered
stack.push(“CS112″);
stack.push(” “);
stack.push(“to”);
stack.push(” “);
stack.push(“Welcome”);
while (!stack.isEmpty()) {
System.out.print(stack.pop()); //Welcome to CS112
}
}
}