Java Collection Tutorial - Java Queue.remove()








Syntax

Queue.remove() has the following syntax.

E remove()

Example

In the following code shows how to use Queue.remove() method.

import java.util.LinkedList;
import java.util.Queue;
/*from  w  ww .  j  a  v  a2 s  .c  om*/
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");

    queue.remove();
    
    System.out.println(queue);
  }
}

The code above generates the following result.