system out println("")/end main(/end class queueapp we've chosen an approach in which queue class fields include not only front and rearbut also the number of items currently in the queuenitems some queue implementations don' use this fieldwe'll show this alternative later the insert(method the insert(method assumes that the queue is not full we don' show it in main()but normally you should only call insert(after calling isfull(and getting return value of false (it' usually preferable to place the check for fullness in the insert(routineand cause an exception to be thrown if an attempt was made to insert into full queue normallyinsertion involves incrementing rear and inserting at the cell rear now points to howeverif rear is at the top of the arrayat maxsize- then it must wrap around to the bottom of the array before the insertion takes place this is done by setting rear to so when the increment occurs rear will become the bottom of the array finally nitems is incremented the remove(method the remove(method assumes that the queue is not empty you should call isempty(to ensure this is true before calling remove()or build this error-checking into remove(removal always starts by obtaining the value at front and then incrementing front howeverif this puts front beyond the end of the arrayit must then be wrapped around to the return value is stored temporarily while this possibility is checked finallynitems is decremented the peek(method the peek(method is straightforwardit returns the value at front some implementations allow peeking at the rear of the array as wellsuch routines are called something like peekfront(and peekrear(or just front(and rear(the isempty()isfull()and size(methods the isempty()isfull()and size(methods all rely on the nitems fieldrespectively checking if it' if it' maxsizeor returning its value implementation without an item count the inclusion of the field nitems in the queue class imposes slight overhead on the insert(and remove(methods in that they must respectively increment and decrement this variable this may not seem like an excessive penaltybut if you're dealing with huge numbers of insertions and deletionsit might influence performance accordinglysome implementations of queues do without an item count and rely on the front and rear fields to figure out whether the queue is empty or full and how many