Vector-based flood-fill algorithm queue class
A note on terminology: What you have implemented is usually called a stack rather than a queue, but it can also be called a LIFO (last in, first out) queue, so it's not wrong to call it a queue, only uncommon.

The nextPixel() method is rather inefficient. You keep track of the number of elements in the queue, and you never do anything that allows any array element with an index &gt;= numberOfElements to be anything but null. So instead of starting the search at elements.length - 1, you should start at numberOfElements - 1.

But that still leaves an inconsistency/inefficiency. The add() method doesn't guard against adding nulls to the queue, but you never return a null until the queue is empty.

You should either return nulls if you accept them to be added to the queue, or, better, I think, guard against nulls in add(). So I'd recommend

public void add(Pixel pixel) {
    if (pixel == null) return; // nothing to do
    // pixel isn't null, add it
    elements[numberOfElements] = pixel;
    ++numberOfElements;
    fixVector();
}


and then - also if you decide to return nulls if they're added - nextPixel() can simply be

public Pixel nextPixel() {
    // queue empty
    if (numberOfElements == 0) return null;
    // decrement numberOfElements and
    // return the last added Pixel
    return elements[--numberOfElements];
}


In fixVector(), you can probably be a bit more efficient if you use the generic Arrays.copyOf method, but maybe you are not allowed to use that either.