LinkedTransferQueue toString() method in Java with Examples Last Updated : 08 Feb, 2019 Comments Improve Suggest changes Like Article Like Report The toString() method of java.util.concurrent.LinkedTransferQueue is an in-built function is Java which is used to return the string representation of the collection. The String representation consists of the elements of the collection enclosed in "[]" and separated by ", ". The order of elements in the spring representation appear in the order of their iteration. Syntax: public String toString () Parameters: This method do not accepts any parameter. Return Value: This method returns a string representation of the collection containing the elements in the same order. Exceptions: No Exceptions are present. Below program illustrates the toString() function of LinkedTransferQueue class : Program 1: Java // Java Program Demonstrate LinkedTransferQueue // toString() method import java.util.concurrent.LinkedTransferQueue; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // create object of LinkedTransferQueue // using LinkedTransferQueue() constructor LinkedTransferQueue<Integer> LTQ = new LinkedTransferQueue<Integer>(); // Add numbers to end of LinkedTransferQueue LTQ.add(101); LTQ.add(202); LTQ.add(58); LTQ.add(796); LTQ.add(641); // Store the string representation of the // collection String object st String st = LTQ.toString(); // Print String representation System.out.println("String Representation: " + st); } } Output: String Representation: [101, 202, 58, 796, 641] Program 2: Java // Java Program Demonstrate LinkedTransferQueue // toString() method import java.util.concurrent.LinkedTransferQueue; import java.util.*; public class GFG { public static void main(String[] args) throws InterruptedException { // create object of LinkedTransferQueue // using LinkedTransferQueue() constructor LinkedTransferQueue<String> LTQ = new LinkedTransferQueue<String>(); // Add numbers to end of LinkedTransferQueue LTQ.add("GeeksforGeeks"); LTQ.add("Gfg"); LTQ.add("gfg"); LTQ.add("Geeks"); LTQ.add("geeks"); // Store the string representation of the // collection String object st String st = LTQ.toString(); // Print String representation System.out.println("String Representation: " + st); } } Output: String Representation: [GeeksforGeeks, Gfg, gfg, Geeks, geeks] Reference: https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/LinkedTransferQueue.html#toString-- Comment More infoAdvertise with us Next Article LinkedTransferQueue toString() method in Java with Examples P ProgrammerAnvesh Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-LinkedTransferQueue +1 More Practice Tags : JavaJava-Collections Similar Reads LinkedTransferQueue toArray() method in Java with Examples public Object[] toArray() The toArray() method of Java.util.concurrent.LinkedTransferQueue is an in-built function is Java which is used to form an array of the same elements as that of LinkedTransferQueue. Basically, it copies all the element to the new array from the LinkedTransferQueue. Syntax: p 3 min read LinkedTransferQueue tryTransfer() method in Java with Examples The tryTransfer() method of class LinkedTransferQueue is an inbuilt function in Java which is generally used to transfer an element to a thread which is waiting to receive it, if in case there is no thread waiting then it will terminate without adding element into the queue or you can also make it w 5 min read LinkedTransferQueue transfer() method in Java with Examples The transfer() method of class LinkedTransferQueue is an inbuilt function in Java which is generally used to transfer an element to a thread which is waiting to receive it, if there is no thread waiting then it will wait till a thread comes to waiting state as soon as waiting thread arrives element 2 min read LinkedBlockingQueue toString() Method in Java with Examples The toString() method of LinkedBlockingQueue returns a String representation of the elements of LinkedBlockingQueue. The string of LinkedBlockingQueue contains its elements from first(head) to last(tail), enclosed in square brackets(â[]â) in proper order. The elements are separated by the characters 2 min read LinkedTransferQueue removeAll() method in Java with Examples The removeAll() method of java.util.concurrent.LinkedTransferQueue is an in-built function is Java which is used to remove from this queue all of its elements that are contained in the specified collection. Syntax: public boolean removeAll(Collection c) Parameters: This method takes collection c as 3 min read LinkedTransferQueue forEach() method in Java with Examples The forEach() method of Java.util.concurrent.LinkedTransferQueue is an in-built function in Java which is used to traverse each element in this queue. Syntax: public void forEach(Consumer<E> action) Parameters: This method takes a parameter action which represents the action to be performed fo 2 min read Level toString() method in Java with Examples The toString() method of java.util.logging.Level is used to get the string value which represents this Level.This method returns a string representation of this Level. Syntax: public String toString() Parameters: This method accepts nothing. Return: This method returns a string representation of thi 1 min read Locale toString() Method in Java with Examples The toString() method of Locale class in Java is used to return a string representation of this locale. Each element i.e., the language, country or the variant of the locale is separated by underbars Syntax: LOCALE.toString() Parameters: This method does not take any parameters. Return Value: This m 1 min read Matcher toString() method in Java with Examples The toString() method of Matcher Class is used to get the String representation of this matcher. This method is derived from the Object Class and behaves in the similar way. Syntax: public String toString() Parameters: This method takes no parameters. Return Value: This method returns a String value 2 min read LongAccumulator toString() method in Java with Examples The java.LongAccumulator.toString() is an inbuilt method in java that returns the String representation of the current value of the LongAccumulator instance. Syntax: public String toString() Parameters: This method does not accepts any parameter. Return Value: This method returns the string represen 2 min read Like