I have a question about the collections group, in particular Queue.
If I have a statement like this:
Queue<E> queue = new LinkedList<E>();
Under which circumstances would it be beneficial to use it.
I used this in this code.
package generation;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;
/**
*
* @author David
*/
public class EconomicLoadOrder<E>
{
Queue<E> queue = new LinkedList<E>();
public EconomicLoadOrder()
{
//Empty constructory
}
public void addGenerator(E gen)
{
this.queue.add(gen);
}
public E getNextGenerator() throws NoSuchElementException
{
return this.queue.remove();
}
}
And I thought I would have been able to use the LinkedList method .pop(). in my getNextGenerator() method, but it seems I can only use the Queue method remove(). This is ok for what I want to do, but I just want to understand what is happening here and why this is so?
I don't intend on changing it, but is there a way of enableing my this.queue object calling poll() ?
regards