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








Syntax

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

boolean add(E e)

Example

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

//from  w  w w.  j  a va2s  .  com
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class Main {

  public static void main(String[] args) {
    Queue<String> queue = new LinkedList<String>();
    queue.add("Hello");
    queue.add("World");
    List<String> list = new ArrayList<String>(queue);

    System.out.println(list);
  }

}

The code above generates the following result.