ConcurrentLinkedQueue isEmpty() method in Java Last Updated : 26 Nov, 2018 Comments Improve Suggest changes Like Article Like Report The isEmpty() method of ConcurrentLinkedQueue is used to check if this queue is empty or not. It returns true if ConcurrentLinkedQueue contains zero number of elements means if the ConcurrentLinkedQueue is empty. Syntax: public boolean isEmpty() Returns: This method returns true if this ConcurrentLinkedQueue contains zero number of elements. Below programs illustrate isEmpty() method of ConcurrentLinkedQueue: Example 1: Java // Java Program Demonstrate isEmpty() // method of ConcurrentLinkedQueue import java.util.concurrent.*; public class GFG { public static void main(String[] args) { // create an ConcurrentLinkedQueue ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<String>(); // Add String to queue queue.add("Aman"); queue.add("Amar"); queue.add("Sanjeet"); queue.add("Rabi"); // Displaying the existing ConcurrentLinkedQueue System.out.println("ConcurrentLinkedQueue: " + queue); // check whether queue isEmpty or not boolean response1 = queue.isEmpty(); // print after applying isEmpty method System.out.println("Is Queue empty: " + response1); } } Output: ConcurrentLinkedQueue: [Aman, Amar, Sanjeet, Rabi] Is Queue empty: false Example 2: Java // Java Program Demonstrate isEmpty() // method of ConcurrentLinkedQueue import java.util.concurrent.*; public class GFG { public static void main(String[] args) { // create an ConcurrentLinkedQueue ConcurrentLinkedQueue<Integer> queue = new ConcurrentLinkedQueue<Integer>(); // Displaying the existing ConcurrentLinkedQueue System.out.println("ConcurrentLinkedQueue: " + queue); // check whether queue is Empty boolean response1 = queue.isEmpty(); // print after applying isEmpty method System.out.println("Is queue empty : " + response1); } } Output: ConcurrentLinkedQueue: [] Is queue empty : true Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html#isEmpty-- Comment More infoAdvertise with us Next Article ConcurrentLinkedQueue isEmpty() method in Java A AmanSingh2210 Follow Improve Article Tags : Java Java-Collections Java - util package java-basics Java-Functions java-queue Java-ConcurrentLinkedQueue +3 More Practice Tags : JavaJava-Collections Similar Reads ConcurrentLinkedQueue add() method in Java The add() method of ConcurrentLinkedQueue is used to insert the element, passed as parameter to add() of ConcurrentLinkedQueue, at the tail of this ConcurrentLinkedQueue. This method returns True if insertion is successful. ConcurrentLinkedQueue is unbounded, so this method will never throw IllegalS 2 min read ConcurrentLinkedQueue contains() method in Java The contains() method of ConcurrentLinkedQueue returns true if ConcurrentLinkedQueue contains the object o, passed as parameter. This method returns true if and only if this ConcurrentLinkedQueue contains at least one element e which is equal to object o passed as parameter i.e. o.equals(e). Syntax: 2 min read ConcurrentLinkedQueue poll() method in Java The poll() method of ConcurrentLinkedQueue is used to remove and return the head of this ConcurrentLinkedQueue. If the ConcurrentLinkedQueue is empty then this method will return null. Syntax: public E poll() Returns: This method remove and returns the head of this ConcurrentLinkedQueue or null if t 2 min read ConcurrentLinkedQueue peek() method in Java The peek() method of ConcurrentLinkedQueue is used to return the head of the ConcurrentLinkedQueue. It retrieves but does not remove, the head of this ConcurrentLinkedQueue. If the ConcurrentLinkedQueue is empty then this method returns null. Syntax: public E peek() Returns: This method returns the 2 min read ConcurrentLinkedDeque isEmpty() method in Java with Examples The java.util.concurrent.ConcurrentLinkedDeque.isEmpty() is an in-built function in Java which checks whether the deque contains elements or not. Syntax: public boolean isEmpty() Parameters: The function does not accepts any parameter. Return: This method returns a boolean value stating whether this 1 min read ConcurrentLinkedQueue offer() method in Java The offer() method of ConcurrentLinkedQueue is used to insert the element, passed as parameter, at the tail of this ConcurrentLinkedQueue. This method returns True if insertion is successful. ConcurrentLinkedQueue is unbounded, so this method offer() will never returns false. Syntax: public boolean 2 min read ConcurrentLinkedQueue addAll() method in Java The addAll() method of ConcurrentLinkedQueue is used to inserts all the elements of the Collection, passed as parameter to this method, at the end of a ConcurrentLinkedQueue. The insertion of element is in same order as returned by the collections iterator. Syntax: public boolean addAll(Collection 4 min read ConcurrentLinkedQueue remove() method in Java The remove(Object o) method of ConcurrentLinkedQueue is used to remove a single instance of the specified element from this ConcurrentLinkedQueue, if it is present. This method removes an element e such that o.equals(e) if this ConcurrentLinkedQueue contains one or more such elements. Remove() metho 2 min read ConcurrentSkipListSet isEmpty() method in Java The java.util.concurrent.ConcurrentSkipListSet.isEmpty() method is an in-built function in Java which is used to check if this set is empty or not. Syntax: ConcurrentSkipListSet.isEmpty() Parameters: The function does not accepts any parameter. Return Value: The function returns a boolean value. It 2 min read ConcurrentHashMap isEmpty() Method in Java The isEmpty() method in Java's ConcurrentHashMap class is used to check whether the map is empty or not. It has the following signature: boolean isEmpty() The isEmpty() method works in a concurrent environment, which means that it can be called from multiple threads without causing any data race or 2 min read Like