Java Collection Tutorial - Java Queue.offer(E e)








Syntax

Queue.offer(E e) has the following syntax.

boolean offer(E e)

Example

In the following code shows how to use Queue.offer(E e) method.

import java.util.LinkedList;
import java.util.Queue;
/*from  w  ww  .  ja  v a  2  s  . co  m*/
public class Main {
  public static void main(String[] args) {
    Queue<String> queue = new LinkedList<String>();
    queue.offer("First");
    queue.offer("Second");
    queue.offer("Third");
    queue.offer("Fourth");

    System.out.println(queue);
  }
}

The code above generates the following result.