About 50 results
Open links in new tab
  1. Best implementation of Java Queue? - Stack Overflow

    Jun 22, 2012 · Queue<String> queue = new LinkedList<String>(); it should be ok,as this is heads-up to users that insertions should occur only at the back and deletions only at the front. You can overcome …

  2. queue - Enqueue, Dequeue and ViewQueue in Java - Stack Overflow

    Java queues don't have enqueue and dequeue methods, these operations are done using the following methods: Enqueuing: add(e): throws exception if it fails to insert the object offer(e): returns false if it …

  3. How do I instantiate a Queue object in java? - Stack Overflow

    Queue in Java is defined as an interface and many ready-to-use implementation is present as part of JDK release. Here are some: LinkedList, Priority Queue, ArrayBlockingQueue, …

  4. Where is the Queue class in the Java Collections?

    Apr 29, 2009 · A Queue is simply a way to look at a collection, so many collections may implement it. As well, things that act like collections but with specific other logic (like thread queues) might use the …

  5. java - How to get a particular element from Queue? - Stack Overflow

    Mar 17, 2014 · Unlike ArrayList, there is no get(int index) method in Queue to retrieve the element at specified position. Anybody please tell me how to achieve this in Queue? Thanks.

  6. Why Java provides two methods to remove element from Queue?

    Sep 26, 2016 · The Queue implementation in Java has two methods to remove element, One is remove() which throws exception and other one is poll() which returns null for an empty queue.

  7. Which concurrent Queue implementation should I use in Java?

    I have 2 scenarios, one requires the queue to support many producers (threads using it) with one consumer and the other is the other way around. I do not understand which implementation to use. …

  8. What is the difference between the add and offer methods in a Queue …

    In Java, the Queue interface provides two methods for adding elements to the queue: add(E e) and offer(E e). Both methods add the specified element to the queue if it is possible to do so immediately …

  9. Initializing a Queue in Java - Stack Overflow

    Mar 8, 2014 · Queue<T> q = ??? I have been searching the internet for the answer for 30+ minutes AND consulted the Java API docs, but I am outright stuck. I know this is a simple question, and because …

  10. Size-limited queue that holds last N elements in Java

    A very simple &amp; quick question on Java libraries: is there a ready-made class that implements a Queue with a fixed maximum size - i.e. it always allows addition of elements, but it will silently