LinkedBlockingDeque isEmpty() method in Java with Example
The isEmpty() method of LinkedBlockingDeque in Java is used to check whether this LinkedBlockingDeque is empty or not. It returns an boolean value stating the same.
Syntax:
public boolean isEmpty()
Parameters: This method does not accepts parameter.
Returns: The method returns an boolean value which states that this instance of the LinkedBlockingDeque is empty or not.
Below examples illustrates the LinkedBlockingDeque.isEmpty() method:
Program 1:
// Java Program Demonstrate isEmpty() // method of LinkedBlockingDeque import java.util.concurrent.LinkedBlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws IllegalStateException { // create object of LinkedBlockingDeque LinkedBlockingDeque<Integer> LBD = new LinkedBlockingDeque<Integer>(); // Add numbers to end of LinkedBlockingDeque LBD.add(7855642); LBD.add(35658786); LBD.add(5278367); LBD.add(74381793); System.out.println("Linked Blocking Deque: " + LBD); // using isEmpty() function System.out.println("Is Linked Blocking Deque empty: " + LBD.isEmpty()); } } |
Linked Blocking Deque: [7855642, 35658786, 5278367, 74381793] Is Linked Blocking Deque empty: false
Program 2:
// Java Program Demonstrate isEmpty() // method of LinkedBlockingDeque // when the list contains characters import java.util.concurrent.LinkedBlockingDeque; import java.util.*; public class GFG { public static void main(String[] args) throws IllegalStateException { // create object of LinkedBlockingDeque LinkedBlockingDeque<String> LBD = new LinkedBlockingDeque<String>(); System.out.println("Linked Blocking Deque: " + LBD); // using isEmpty() function System.out.println("Is Linked Blocking Deque empty: " + LBD.isEmpty()); } } |
Linked Blocking Deque: [] Is Linked Blocking Deque empty: true
Recommended Posts:
- LinkedBlockingDeque add() method in Java
- LinkedBlockingDeque contains() method in Java
- LinkedBlockingDeque put() method in Java
- LinkedBlockingDeque take() method in Java
- LinkedBlockingDeque pop() method in Java
- LinkedBlockingDeque pollLast() method in Java
- LinkedBlockingDeque pollFirst() method in Java
- LinkedBlockingDeque poll() method in Java
- LinkedBlockingDeque drainTo() method in Java with Example
- LinkedBlockingDeque descendingIterator() method in Java
- LinkedBlockingDeque removeLast() method in Java
- LinkedBlockingDeque hashCode() method in Java with Example
- LinkedBlockingDeque removeFirst() method in Java
- LinkedBlockingDeque peekFirst() method in Java
- LinkedBlockingDeque addFirst() method in Java
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.



