VOOZH about

URL: https://www.geeksforgeeks.org/java/linkedblockingqueue-tostring-method-in-java/

⇱ LinkedBlockingQueue toString() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

LinkedBlockingQueue toString() method in Java

Last Updated : 18 Sep, 2018
The toString() method of LinkedBlockingQueue returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). The adjacent elements are separated by the characters ", " (comma and space). The elements are converted to strings as by String.valueOf(Object). Syntax:
public String toString()
Parameters: This method does not accept any parameters. Returns: This method returns a string representation of this collection. Below programs illustrate toString() method of LinkedBlockingQueue: Program 1:
Output:
Linked Blocking Queue: [7855642, 35658786, 5278367, 74381793]
Linked Blocking Queue in string [7855642, 35658786, 5278367, 74381793]
Program 2:
Output:
Linked Blocking Queue: [gopal, gate, GRE, CAT]
Linked Blocking Queue in string [gopal, gate, GRE, CAT]
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/LinkedBlockingQueue.html#toString--
Comment