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.
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:
Vector: [Geeks, 4, Geeks, Welcomes, You] The String representation is: [Geeks, 4, Geeks, Welcomes, You]
Initial Vector is: [10, 15, 20, 25, 30] The String representation is: [10, 15, 20, 25, 30]
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.