Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 15th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.LinkedList;
  2.  
  3. public class Test {
  4.  
  5.         public static void main(String[] args) {
  6.                 LinkedList<Integer> stack = new LinkedList<Integer>();
  7.                
  8.                 for(int i = 0; i < 5; i++) {
  9.                         stack.push(i);
  10.                 }
  11.                
  12.                 System.out.println("stack");
  13.                 while(stack.isEmpty() == false) {
  14.                         System.out.println(stack.pop());
  15.                 }
  16.                
  17.                 LinkedList<Integer> queue = new LinkedList<Integer>();
  18.                
  19.                 for(int i = 0; i < 5; i++) {
  20.                         queue.add(i);
  21.                 }
  22.                
  23.                 System.out.println("queue");
  24.                 while(queue.isEmpty() == false) {
  25.                         System.out.println(queue.remove());
  26.                 }
  27.         }
  28. }