LinkedTransferQueue size() method in Java Last Updated : 14 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.util.concurrent.LinkedTransferQueue.size() method is an in-built function in Java which gives the total count of the elements present in the queue. Syntax: LinkedTransferQueue.size() Parameters: The function does not accept any parameter. Return Value: The function returns the number of elements in the queue. Below programs illustrate the LinkedTransferQueue.size() method: Program 1: Java // Java Program Demonstrate size() // method of LinkedTransferQueue import java.util.concurrent.LinkedTransferQueue; class LinkedTransferQueueSizeExample1 { public static void main(String[] args) { // Initializing the queue LinkedTransferQueue<Integer> queue = new LinkedTransferQueue<Integer>(); // Adding elements to this queue for (int i = 1; i <= 10; i++) queue.add(i); // Printing the size of the queue System.out.println("Number of elements in the queue = " + queue.size()); // Printing the elements System.out.println("Queue : " + queue); } } Output: Number of elements in the queue = 10 Queue : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Program 2: Java // Java Program Demonstrate size() // method of LinkedTransferQueue import java.util.concurrent.LinkedTransferQueue; class LinkedTransferQueueSizeExample2 { public static void main(String[] args) { // Initializing the queue LinkedTransferQueue<String> queue = new LinkedTransferQueue<String>(); // Adding elements to this queue queue.add("A"); queue.add("B"); queue.add("C"); queue.add("D"); queue.add("E"); // Printing the size of the queue System.out.println("Number of elements in the queue = " + queue.size()); // Printing the elements System.out.println("Queue : " + queue); } } Output: Number of elements in the queue = 5 Queue : [A, B, C, D, E] Reference: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/LinkedTransferQueue.html#size() Comment More infoAdvertise with us Next Article LinkedTransferQueue take() 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 take() method in Java The java.util.concurrent.LinkedTransferQueue.take() method is an in-built function in Java which retrieves and remove the first element of the queue. This method also waits (if necessary) until an element becomes available. Syntax: LinkedTransferQueue.take() Parameters: The function does not accept 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 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 offer() method in Java offer(E e, long timeout, TimeUnit unit) The offer(E e, long timeout, TimeUnit unit) method of java.util.concurrent.LinkedTransferQueue Class is an in-built function in Java which inserts the element passed as parameter to method at the tail of this queue, if queue is not full. It will wait till a sp 4 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 remove() method in Java The java.util.concurrent.LinkedTransferQueue.remove() method is an in-built function in Java which is used to remove an element if it is present in this queue. Syntax: LinkedTransferQueue.remove(Object o) Parameters: The function accepts a single parameter o i.e. the object to be removed. Return Val 2 min read Like