class Queue <T> {
private T[] q;
...
}
...
Queue<Integer> = new Queue<>();
public class Queue<T> {
T q[]; // Array to storage elements in queue
int putloc, getloc;
// indexes of placement and extracting queue elements
Queue(int size) { q = (T[])new Object[size+1];;
// allocate memory for queue
putloc = getloc = 0; }
// put symbol in queue
void put(T ch) {
if(putloc==q.length-1) {
System.out.println(" - Queue is full.");
return; }
putloc++;
q[putloc] = ch; }
// extract symbol from the queue
T get() {
if(getloc == putloc) {
System.out.println(" - Queue is empty.");
return null; }
getloc++;
return q[getloc];
}
}
Queue<int> queue = new Queue<>(5); // не правильно
Queue<Integer> queue = new Queue<>(5); // правильно