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 deque is empty or not.

Below programs illustrate the ConcurrentLinkedDeque.isEmpty() method:

Example: 1

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program Demonstrate
// isEmpty() method of ConcurrentLinkedDeque
  
import java.util.concurrent.*;
  
class ConcurrentLinkedDequeDemo {
    public static void main(String[] args)
    {
        ConcurrentLinkedDeque<String> cld
            = new ConcurrentLinkedDeque<String>();
  
        // Displaying the existing LinkedDeque
        System.out.println("ConcurrentLinkedDeque: "
                           + cld);
  
        // Check if the queue is empty
        // using isEmpty() method
        System.out.println("Is deque empty: "
                           + cld.isEmpty());
    }
}

chevron_right


Output:

ConcurrentLinkedDeque: []
Is deque empty: true

Example: 2

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program Demonstrate
// isEmpty() method of ConcurrentLinkedDeque
  
import java.util.concurrent.*;
  
class ConcurrentLinkedDequeDemo {
    public static void main(String[] args)
    {
        ConcurrentLinkedDeque<String> cld
            = new ConcurrentLinkedDeque<String>();
  
        cld.add("GFG");
        cld.add("Gfg");
        cld.add("GeeksforGeeks");
        cld.add("Geeks");
  
        // Displaying the existing LinkedDeque
        System.out.println("ConcurrentLinkedDeque: "
                           + cld);
  
        // Check if the queue is empty
        // using isEmpty() method
        System.out.println("Is deque empty: "
                           + cld.isEmpty());
    }
}

chevron_right


Output:

ConcurrentLinkedDeque: [GFG, Gfg, GeeksforGeeks, Geeks]
Is deque empty: false


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.