public void enqueue(Item item) {
        if (item == null)
            throw new NullPointerException();
        if (next == a.length)
            resize(2 * a.length);
        a[next] = item;
        next++;
        size++;
    }