java – Randomized Queue with ArrayList from Princeton’s Algorithm Book

In the book they recommend to utilize an Array, but I think that it’s easier to use an ArrayList instead, is there any problem with that? Is this code well designed?

package com.company;

import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Random;

public class RandomQueue<Item>{
    private ArrayList<Item> a;
    private int size;
    Random r;

    public RandomQueue(){
        a = new ArrayList<Item>();
        size = 0;
    }
    
    public int size(){
        return size;
    }
    
    public boolean isEmpty(){
        return size == 0;
    }
    
    public void enqueue(Item item){
        a.add(item);
        size++;
    }
    
    public Item dequeue(){
        if(isEmpty()){
            throw new NoSuchElementException("Queue is empty");
        }else {
            r = new Random();
            int randomIndex = r.nextInt(size);
            Item item = a.get(randomIndex);
            a.remove(randomIndex);
            size--;
            return item;
        }
    }
    
    public Item sample(){
        r = new Random();
        if(isEmpty()){
            throw new IndexOutOfBoundsException();
        }
    
        int index = r.nextInt(size);
        return a.get(index);
    }

}