Vector toString() method in Java with Example Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report 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: Java // Java code to illustrate the toString() method import java.util.*; public class GFG { public static void main(String[] args) { // creating vector type object Vector<String> vector = new Vector<String>(); // Inserting elements into the table vector.add("Geeks"); vector.add("4"); vector.add("Geeks"); vector.add("Welcomes"); vector.add("You"); // Displaying the Vector System.out.println("Vector: " + vector); // Displaying the string representation System.out.println("The String representation is: " + vector.toString()); } } Output: Vector: [Geeks, 4, Geeks, Welcomes, You] The String representation is: [Geeks, 4, Geeks, Welcomes, You] Program 2: Java // Java code to illustrate the toString() method import java.util.*; public class GFG { public static void main(String[] args) { // Creating an empty Vector Vector<Integer> vector = new Vector<Integer>(); // Inserting elements into the table vector.add(10); vector.add(15); vector.add(20); vector.add(25); vector.add(30); // Displaying the Vector System.out.println("Initial Vector is: " + vector); // Displaying the string representation System.out.println("The String representation is: " + vector.toString()); } } Output: Initial Vector is: [10, 15, 20, 25, 30] The String representation is: [10, 15, 20, 25, 30] Comment A ankit15697 Follow 2 Improve A ankit15697 Follow 2 Improve Article Tags : Java Technical Scripter Java-Collections Java - util package Java-Functions Java-Vector +2 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like