forked from Hithomelabs/Princeton1
23 lines
714 B
Java
23 lines
714 B
Java
package com.hithomelabs.clients.module4;
|
|
|
|
|
|
import com.hithomelabs.princeton1.module4.LinkedStack;
|
|
import com.hithomelabs.princeton1.module4.Stack;
|
|
|
|
public class LinkedStackClient {
|
|
public static void main(String[] args) {
|
|
Stack<String> stack = new LinkedStack<String>();
|
|
stack.push("hello");
|
|
stack.push("world");
|
|
stack.push("I");
|
|
stack.push("am");
|
|
stack.push("using");
|
|
stack.push("stacks");
|
|
// Using object s, as stack is generic but every java Object has implementation of toString()
|
|
for (Object s : stack)
|
|
System.out.println(s);
|
|
while(!stack.isEmpty()){
|
|
System.out.println(stack.pop());
|
|
}
|
|
}
|
|
} |