VOOZH about

URL: https://www.geeksforgeeks.org/java/vector-tostring-method-in-java-with-example/

⇱ Vector toString() method in Java with Example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Vector toString() method in Java with Example

Last Updated : 11 Jul, 2025

The java.util.Vector.toString() is an inbuilt method of Vector that is used to get a string representation of the objects of Vector in the form of a String representation of entries separated by ", ". So basically the toString() method is used to convert all the elements of Vector into String.
Syntax: 

Vector.toString()


Parameter: The method does not take any parameters.
Return value: The method returns the String representation consisting of the string representation of the elements of the Vector.
Below programs illustrate the working of java.util.Vector.toString() method:
Program 1:
 


Output: 
Vector: [Geeks, 4, Geeks, Welcomes, You]
The String representation is: [Geeks, 4, Geeks, Welcomes, You]

 

Program 2: 
 


Output: 
Initial Vector is: [10, 15, 20, 25, 30]
The String representation is: [10, 15, 20, 25, 30]

 
Comment