public class StaticQueue { // Constant specifying the maximum queue size public static final int DEFAULT_SIZE = 1000; // Add x to queue q at index i, which must be // the end of the queue public static void add( int[] q, int i, int x ) { q[i] = x; } // Return element of queue at index i, which must // be the head of the queue public static int view( int[] q, int i ) { return q[i]; } // Remove element of queue at index i, which must // be the head of the queue public static void remove( int[] q, int i ) { q[i] = 0; // optional } // Create a queue, add elements to it, view elements, // and remove elements public static void main(String[] args) { int[] q1 = new int[DEFAULT_SIZE]; // BAD: head and end of queue maintained here // in main(); better to abstract this out // and hide implementation details int q1Front = 0; int q1End = 0; add( q1, q1End++, 57 ); add( q1, q1End++, 59 ); add( q1, q1End++, 64 ); System.out.println( view( q1, q1Front ) ); remove( q1, q1Front++ ); System.out.println( view( q1, q1Front ) ); remove( q1, q1Front++ ); System.out.println( view( q1, q1Front ) ); remove( q1, q1Front++ ); } }