
Untitled
By: a guest on
Apr 15th, 2012 | syntax:
None | size: 0.56 KB | hits: 9 | expires: Never
import java.util.LinkedList;
public class Test {
public static void main(String[] args) {
LinkedList<Integer> stack = new LinkedList<Integer>();
for(int i = 0; i < 5; i++) {
stack.push(i);
}
System.out.println("stack");
while(stack.isEmpty() == false) {
System.out.println(stack.pop());
}
LinkedList<Integer> queue = new LinkedList<Integer>();
for(int i = 0; i < 5; i++) {
queue.add(i);
}
System.out.println("queue");
while(queue.isEmpty() == false) {
System.out.println(queue.remove());
}
}
}