This interface is a member of the Java Collections Framework.
Return | Method | Summary |
---|---|---|
boolean | add(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. |
E | element() | Retrieves, but does not remove, the head of this queue. |
boolean | offer(E e) | Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. |
E | peek() | Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. |
E | poll() | Retrieves and removes the head of this queue, or returns null if this queue is empty. |
E | remove() | 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. |