Source of 10.4.java


  1: QueueInterface<String> myQueue = new LinkedQueue<>();
  2: myQueue.enqueue("Jim");
  3: myQueue.enqueue("Jess");
  4: myQueue.enqueue("Jill");
  5: myQueue.enqueue("Jane");
  6: myQueue.enqueue("Joe");
  7: 
  8: String front = myQueue.getFront(); // Returns "Jim"
  9: System.out.println(front + " is at the front of the queue.");
 10: 
 11: front = myQueue.dequeue();         // Removes and returns "Jim"
 12: System.out.println(front + " is removed from the queue.");
 13: 
 14: myQueue.enqueue("Jerry");
 15: 
 16: front = myQueue.getFront();        // Returns "Jess"
 17: System.out.println(front + " is at the front of the queue.");
 18: 
 19: front = myQueue.dequeue();         // Removes and returns "Jess"
 20: System.out.println(front + " is removed from the queue.");
 21: // Version 4.0