Queue length of an object
<p>I've following queue class:</p>

<pre><code>class Queue
{

    private Object[] data;
    private int numOfElements;
    private int head;
    private int tail;


    Queue(int size)
    {
        if (size &lt;= 0)
            throw new IllegalArgumentException("Size must be greater or equals 0.");

        data = new Object[size];
        head = 0;
        tail = 0;
        numOfElements = 0;
    }

    void enqueue(Object obj)
    {
        data[tail] = obj;
        tail = (tail + 1) % data.length;

        if (numOfElements &lt; data.length)
            numOfElements++;
    }

    Object dequeue()
    {
        if (numOfElements == 0)
            throw new EmptyQueueException();

        Object dequeuedObject = data[head];
        data[head] = null;
        head = (head + 1) % data.length;

        numOfElements--;

        return dequeuedObject;
    }
</code></pre>

<p>I call the method enqueue like this: <code>test_queue.enqueue(new Event(arg1, arg2));</code></p>

<p>The <code>Event</code> object contains two integers which are set to the values of arg1 and arg2. How does <code>data.length</code> inside method <code>enqueue</code> work?
How can it get the size of the Event object correctly?</p>
