LinkedTransferQueue isEmpty() method in Java Last Updated : 14 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The isEmpty() method of java.util.concurrent.LinkedTransferQueue is an in-built function in Java which checks if this queue is empty or not. Syntax: LinkedTransferQueue.isEmpty() Return Value: The function returns a boolean value. It returns true if the LinkedTransferQueue is empty and returns false otherwise. Below programs illustrate the LinkedTransferQueue.isEmpty() method: Program 1: In this program the LinkedTransferQueue is non-empty. Java // Java Program Demonstrate isEmpty() // method of LinkedTransferQueue import java.util.concurrent.*; class LinkedTransferQueueIsEmptyExample1 { public static void main(String[] args) { // Initializing the queue LinkedTransferQueue<Integer> queue = new LinkedTransferQueue<Integer>(); // Adding elements to this queue for (int i = 10; i <= 15; i++) queue.add(i); // Checks if this queue is empty or not if (queue.isEmpty()) System.out.println("The queue is empty."); else System.out.println("The queue is non-empty."); } } Output: The queue is non-empty. Program 2:In this program the LinkedTransferQueue is empty. Java // Java Program Demonstrate isEmpty() // method of LinkedTransferQueue */ import java.util.concurrent.*; class LinkedTransferQueueIsEmptyExample2 { public static void main(String[] args) { // Initializing the queue LinkedTransferQueue<Integer> queue = new LinkedTransferQueue<Integer>(); // Checks if this queue is empty or not if (queue.isEmpty()) System.out.println("The queue is empty."); else System.out.println("The queue is non-empty."); } } Output: The queue is empty. Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/LinkedTransferQueue.html#isEmpty() Comment More infoAdvertise with us Next Article LinkedTransferQueue put() method in Java R rupesh_rao Follow Improve Article Tags : Misc Java Java-Collections Java - util package Java-Functions Java-LinkedTransferQueue +2 More Practice Tags : JavaJava-CollectionsMisc Similar Reads LinkedTransferQueue drainTo() method in Java drainTo(Collection c) The drainTo(Collection c) method of java.util.concurrent.LinkedTransferQueue Class is an in-built function in Java which removes all the elements present in this queue and adds them to the provided collection. This is a more efficient way than repeatedly polling this queue. The 5 min read LinkedTransferQueue contains() method in Java The contains() method of java.util.concurrent.LinkedTransferQueue is an in-built function in Java which returns a true boolean value if the specified element is present in this queue otherwise it returns false. Syntax: LinkedTransferQueue.contains(Object o) Parameters: The function accepts a single 2 min read LinkedTransferQueue put() method in Java The java.util.concurrent.LinkedTransferQueue.put() method is an in-built function in Java which is used to insert an element in this queue. It waits till the space becomes available if queue is full. Syntax: LinkedTransferQueue.put(E e) Parameters: The function accepts a single parameter e i.e. the 2 min read LinkedTransferQueue add() method in Java The add() method of java.util.concurrent.LinkedTransferQueue is an in-built function in Java which is used to insert an element in this queue. Syntax: LinkedTransferQueue.add(E e) Parameters: The function accepts a single parameter e i.e. the element to be inserted. Return Value: The function return 2 min read LinkedTransferQueue poll() method in Java The java.util.concurrent.LinkedTransferQueue.poll() method is an in-built function in Java which retrieves and remove the head of the queue if the queue is non-empty. Syntax: LinkedTransferQueue.poll() Parameters: The function does not accept any parameter. Return Value: The function returns the hea 2 min read LinkedTransferQueue peek() method in Java The java.util.concurrent.LinkedTransferQueue.peek() method is an in-built function in Java which is used to return the head of the queue if the queue is non-empty. Syntax: LinkedTransferQueue.peek() Parameters: The function does not accept any parameter. Return Value: The function returns the head o 2 min read Like