public class ArrayQueueUser2 // test out the ArrayQueue2 with an example queue of int values { // @SuppressWarnings("unchecked") - not needed since we are not dealing with casting or generics public static void main(String[] args) { ArrayQueue2 queue=new ArrayQueue2(6); // create a small queue to show exceptions try { for(int i=0;i<10;i++) // enqueue 10 elements, because of size of queue, will throw QueueFullException { System.out.println("Enqueuing " + i); queue.enqueue(i); } } catch(QueueFullException e) { System.out.println(e); } try { while(!queue.isEmpty()) // dequeue all 6 elements so that we have an "empty" queue System.out.println(queue.dequeue()); } catch(QueueEmptyException e) { System.out.println(e); } try { System.out.println("Queue's current size is " + queue.getSize()); // get the size to show queue is empty for(int i=10;i<20;i++) // start adding more elements - we can't, queue is full, why? { System.out.println("Enqueuing " + i); queue.enqueue(i); } } catch(QueueFullException e) { System.out.println(e); } } }