I've been trying to double the size of my queue and I have tried several different methods, this one has given me the closest result to what I am trying to get, however, it copies all the values already in the queue into the newly created spaces instead of leaving them empty for me to add more objects.
I have two classes, and the only part I need to change is the enqueue method.

[![enter image description here](https://i.stack.imgur.com/DCia3.png)](https://i.stack.imgur.com/DCia3.png)

The last line should print 50 40 30 20 60 70 instead.

```
public class Queue{
    private int QUEUE_SIZE = 5;
    private Object[] items;
    private int front, back, count;
    public Queue() {
        items = new Object[QUEUE_SIZE];
        front = 0;
        back = QUEUE_SIZE -1;
        count =0;
    }
    public boolean isEmpty(){
        return count ==0;
    }
    public boolean isFull(){
        return count == QUEUE_SIZE;
    }
    public void enqueue(Object newItem){
        if (!isFull()){
            back = (back+1) % QUEUE_SIZE;
            items[back] = newItem;
            count++;
            return;
        } else
            System.out.println("Queue is full. Doubling the size.");
            count = (QUEUE_SIZE*2);
            System.out.println("New max size is: " + QUEUE_SIZE);
    }
    public Object dequeue(){
        if (!isEmpty()){
            Object queueFront = items[front];
            front = (front+1) % QUEUE_SIZE;
            count--;
            return queueFront;
        }else
            System.out.println("Trying to dequeue from empty queue");
        return null;
    }
    public void dequeueAll(){
        items = new Object[QUEUE_SIZE];
        front = 0;
        back = QUEUE_SIZE -1;
        count =0;
    }
    public Object peek(){
        if (!isEmpty()) {
            return items[front];
        }
        else
            System.out.println("Trying to peek with empty queue");
        return null;
    }

    public int size(){
        return count;
    }

}

import java.util.Stack;

public class Runner {

    public static void main(String[] args) {
    Queue q = new Queue();
    createQueue(q);
    System.out.println("My queue is as follows: ");
    printQueue(q);
    System.out.println("I am going to dequque one element.");
    q.dequeue();
    System.out.println("My queue is as follows: ");
    printQueue(q);
    System.out.println("I am going to reverse my queue: ");
    reverseQueue(q);
    System.out.println("My queue is as follows: ");
    printQueue(q);
    System.out.println("I am going to enqueue 60.");
    q.enqueue(60);
    System.out.println("My queue is as follows: ");
    printQueue(q);
    System.out.println("I am going to enqueue 70.");
    q.enqueue(70);
    System.out.println("My queue is as follows: ");
    printQueue(q);
    }

    public static Queue createQueue(Queue q){
        q.enqueue(10);
        q.enqueue(20);
        q.enqueue(30);
        q.enqueue(40);
        q.enqueue(50);
        return q;
    }

    public static void printQueue(Queue q){
        int s = q.size();

        for(int i=0; i<s; i++){
            int temp = (int)q.dequeue();
            q.enqueue(temp);
            System.out.print(temp+ " ");
        }
        System.out.println();
    }

    public static void reverseQueue(Queue q){
        Stack s = new Stack();
        while(!q.isEmpty()){
            s.push(q.dequeue());
        }while(!s.isEmpty()){
            q.enqueue(s.pop());
        }
    }

}

```