Queues

A Queue is a first-in-first-out collection of objects. An example of a queue is a line of waiting at a traffic light. The first car that arrived will be the first that leaves when the light turns green. New cars arriving are added to the end of the line. Then all cars will leave in the order they arrived.

I have created a class called ArrayQueue which implements a Queue. It has a contructor and three methods:

public ArrayQueue(int maxLength)
The constructor takes an argument that represents the maximum possible number of objects in the Queue.
public void insert(Object o)
Inserts a new object at the end of the Queue
public Object remove()
removes objects in the order they were inserted and returns the object removed
public int getLength()
Returns the number of objects in the Queue

QueueApp is an application which demonstates the ArrayQueue class. ArrayQueue implements the Queue interface.

Note the limitations of this array-based implementation of a Queue.