The AbstractQueue class in Java is a part of the Java Collection Framework and implements the Collection interface and the AbstractCollection class. It provides skeletal implementations of some Queue operations. The implementations in this class are appropriate when the base implementation does not allow null elements.
java.lang.Object ↳ java.util.AbstractCollection<E> ↳ Class AbstractQueue<E>
public abstract class AbstractQueue<E> extends AbstractCollection<E> implements Queue<E> Where E is the type of element maintained by this collection class.
Constructors in Java AbstractQueue:
- protected AbstractQueue(): The default constructor, but being protected, it doesn’t allow to create an AbstractQueue object.
Below is a sample program to illustrate AbstractQueue in Java:
AbstractQueue contains: [10, 20, 30, 40, 50]
Methods in Java AbstractQueue:
- 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.
- addAll(Collection extends E> c): Adds all of the elements in the specified collection to this queue.
- clear(): Removes all of the elements from this queue.
- element(): Retrieves, but does not remove, the head of this queue.
- remove(): Retrieves and removes the head of this queue.
- AbstractQueue add() method in Java with examples
- AbstractQueue clear() method in Java with examples
- AbstractQueue element() method in Java with examples
- AbstractQueue addAll() method in Java with examples
- AbstractQueue remove() method in Java with examples
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.util.BitSet class in Java with Examples | Set 1
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.Collections.frequency() in Java with Examples
- Java.util.Arrays.equals() in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java 8 | Consumer Interface in Java with Examples
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java 8 | ArrayDeque removeIf() method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
AbstractQueue contains: [10, 20, 30, 40, 50] Head: 10 AbstractQueue: 
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.