Dynamic Queue implementation using arrays. A queue is a kind of abstract data type or collection in which the entities in the collection are kept in order and the only operations on the collection are the addition of entities to the rear terminal position, called as enqueue, and removal of entities from the front terminal position, called as dequeue.
Disclaimer: I'm not a Java guy. This If needs some breathing space. Public void enQueue(T value) if ((rear+1)%sizefront) It would be much more readable like this: if ((rear + 1)% size front). Same goes for this statement later in the same enQueue method.
Rear=(rear+1)%size;. Actually, it looks like you could extract a function there.
deQueue also suffers from inconsistent (and poor) whitespace. I know it's just an example implementation to show us that it works, but QueueImpl is a poor name. There's no reason to abbrv names. It's not the 1960's. We're not counting bytes in our names anymore. Prefer clear, concise, and meaningful names over shortened ones. Speaking of the example implementation, it would be better to write an actual Unit Test than to print to the console.
The size field is not required (just use queue.length) In fact, the size field is a misnomer, because it is the capacity, not the size. The size is the number of elements that the queue actually contains, while the capacity is the maximum number of elements that it can hold. In enQueue, you have a special case for the empty queue, and in deQueue you have a special case for the singleton queue.
![Java program to implement circular queue adt using an array to find excel Java program to implement circular queue adt using an array to find excel](/uploads/1/2/5/3/125396533/107428135.jpg)
![Array Array](/uploads/1/2/5/3/125396533/164653538.png)
These special cases are avoidable. Instead of representing the empty queue with head rear -1 you could keep a separate size field (to remember how many elements are in the queue). Or you could use a different invariant: queue empty iff head rear queue full iff rear (head+1)% queue.length.