Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
LinkedTransferQueue toString() method in Java with Examples
Next article icon

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--

Next Article
LinkedTransferQueue toString() method in Java with Examples

P

ProgrammerAnvesh
Improve
Article Tags :
  • Java
  • Java-Collections
  • Java - util package
  • Java-Functions
  • Java-LinkedTransferQueue
Practice Tags :
  • Java
  • Java-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 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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences