'How to add elements into array from a queue?

Im trying to create a waiting list which will hold names of customers in a static array when the main array is full.and When the main array gets an EMPTY slot the first customer in the waiting list array will fill up the EMPTY slot of main array and the added element will be removed Im trying to create this in a circular queue implementation. but I cannot get it to add the other queue elements when main array gets empty

import java.util.Scanner;

public class CQueue {

    int SIZE = 4; 
    int front, rear;
    int items[] = new int[4];

    void initialize (String[]task) {
        for (int i = 0; i < task.length; i++) {
            task[i] = "FULL";
        }
    }

    CQueue() {
        front = -1;
        rear = -1;
    }

    boolean isFull() {
        if (front == 0 && rear == SIZE - 1) {
            return true;
        }
        if (front == rear + 1) {
            return true;
        }
        return false;
    }

    boolean isEmpty() {
        if (front == -1)
            return true;
        else
            return false;
    }

    void enQueue(int element) {
        if (isFull()) {
            System.out.println("Queue is full");
        } else {
            if (front == -1)
                front = 0;
            rear = (rear + 1) % SIZE;
            items[rear] = element;
            System.out.println("Inserted " + element);
        }
    }


    int deQueue() {
        int element;
        if (isEmpty()) {
            System.out.println("Queue is empty");
            return (-1);
        } else {
            element = items[front];
            if (front == rear) {
                front = -1;
                rear = -1;
            } 
            else {
                front = (front + 1) % SIZE;
            }
            return (element);
        }
    }

    void display() {
        int i;
        if (isEmpty()) {
            System.out.println("Empty Queue");
        } else {
            System.out.println("Front -> " + front);
            System.out.println("Items -> ");
            for (i = front; i != rear; i = (i + 1) % SIZE)
                System.out.print(items[i] + " ");
            System.out.println(items[i]);
            System.out.println("Rear -> " + rear);
        }
    }
 void deleteArr(String task[]) {
    CQueue q = new CQueue();
    int NUM;
    Scanner sc = new Scanner(System.in);
    System.out.print("Enter customer num to delete : ");
    NUM = sc.nextInt()-1;
    task[NUM] = "EMPTY";
    int element = items[front];
    task[NUM]=Integer.toString(element);
    q.deQueue();
    q.display();
}


    public static void main(String[] args) {
        int k =1;
        String task[] = new String[12];
        CQueue q = new CQueue();
        q.initialize(task);
        q.display();
        for (int i = 0; i < task.length; i++) {
            if (task[i].equals("FULL")) {
                q.enQueue(k);
                k++;
            }
        }
        while (true) {
            q.deleteArr(task);
            for (int j = 0; j < task.length; j++) {
                System.out.println(task[j]);
            }
        }

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source