Exemplo n.º 1
0
 public static void main(String[] args) {
   Solution34 sol34 = new Solution34();
   int[] values = new int[] {11, 34, 2, 6, 23, 5, 10};
   System.out.print("Create the queue: ");
   MyQueue queue = sol34.new MyQueue(values);
   sol34.printOutQueue(values);
   System.out.print("Remove three elements: ");
   for (int i = 0; i < 3; i++) {
     System.out.print(queue.remove() + "  ");
   }
   System.out.println();
   System.out.print("Peek the next element: ");
   System.out.print(queue.peek());
   System.out.println();
   System.out.print("Add one element 0 and print out all current queue: ");
   queue.add(0);
   while (!queue.isEmpty()) {
     System.out.print(queue.remove() + "  ");
   }
 }