Queue

This interface is a member of the Java Collections Framework.

ReturnMethodSummary
booleanadd(E e)Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
Eelement()Retrieves, but does not remove, the head of this queue.
booleanoffer(E e)Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
Epeek()Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
Epoll()Retrieves and removes the head of this queue, or returns null if this queue is empty.
Eremove()Retrieves and removes the head of this queue.

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("A");
    queue.add("B");
    queue.add("ja v a2s.com"); 


    System.out.println(queue);
  }

}
  

The output:


[A, B, ja v a2s.com]
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.