Printing a queue of type enum

typedef enum {A,B,C,D,E,F,G,H,I,J} color;

class balls#(NUM=10);
  
  rand color q1[$]; //declared a bounded queue with 10 elements of enum type
  
endclass

module top();
  
  balls#(10) b= new();
  
  initial begin
    $display ("#############");
    repeat (5) begin
      b.randomize();
      $display ("%p", b.q1);
    end
    $display ("#############");
  end
    
endmodule

Hi, Please let me know what am I doing wrong in the above code I’m simply trying to print the queue of enum type color.
My queue is not getting printed with enum values instead I am getting all null queues : shown below

#############
'{}
'{}
'{}
'{}
'{}
#############

In reply to sk7799:

Your q1 is empty (size is 0).
You need to specify a size for q1.
Try the same code with :

    b.randomize() with {q1.size()==10;};

In reply to KillSteal:

Hi,

Can I restrain the size of the queue using

rand color q1[$:NUM-1];

Is this the same as giving a size to the queue ?

Please let me know. Thanks in advance.

In reply to sk7799:

That is a limit to the queue size; it does not allocate any elements. That limit makes queues synthesizable.

P.S. Please use code tags making your code easier to read. I have added them for you.