Vector toString() method in Java with Example Last Updated : 29 Jul, 2021 Comments Improve Suggest changes Like Article 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 More infoAdvertise with us Next Article Vector toString() method in Java with Example A ankit15697 Follow Improve Article Tags : Java Technical Scripter Java-Collections Java - util package Java-Functions Java-Vector +2 More Practice Tags : JavaJava-Collections Similar Reads Vector removeAll() Method in Java The java.util.vector.removeAll(Collection col) method is used to remove all the elements from the vector, present in the collection specified. Syntax: Vector.removeAll(Collection col) Parameters: This method accepts a mandatory parameter col which is the collection whose elements are to be removed f 2 min read Vector removeAllElements() method in Java with Example The Java.util.Vector.removeAllElements() method is used to removes all components from this Vector and sets its size to zero. Syntax: Vector.removeAllElements() Parameters: The method does not take any parameter Return Value: The function does not returns any value. Below programs illustrate the Jav 2 min read Vector removeElement() method in Java with Example The java.util.Vector.removeElement() method is used to remove first occurrence of particular object. If object is not found then it returns false else it returns true. If a particular object is present inside vector and removeElement() method call on that vector element then this method reduces vect 3 min read Vector removeElementAt() Method in Java The java.util.vector.removeElementAt(int index) method is used to remove an element from a Vector from a specific position or index. In this process the size of the vector is automatically reduced by one and all other elements after the removed element are shifted downwards by one position. Syntax: 2 min read Vector removeIf() method in Java The removeIf() method of Vector removes all of those elements from Vector which satisfies the condition passed as a parameter to this method. This method returns true if some element are removed from the Vector. Java 8 has an important in-built functional interface which is Predicate. Predicate, or 3 min read Vector removeRange() method in Java with Example The removeRange() method of Vector in Java is used to remove all elements within the specified range from an Vector object. It shifts any succeeding elements to the left. This call shortens the Vector by (toIndex-fromIndex) elements where toIndex is the ending index and fromIndex is the starting ind 3 min read Vector retainAll() method in Java with Examples The retainAll method of class vector in java is an inbuilt function in Java which is used to retains only the elements in this Vector that are contained in the specified Collection. In other words, removes from this Vector all of its elements that are not contained in the specified Collection. Synta 3 min read Vector setElementAt() method in Java with Example The setElementAt() method of Java Vector is used to set the component at the specified index of this vector to be the specified object. The previous component at that position is discarded. The index must be a value greater than or equal to 0 and less than the current size of the vector. Syntax: pub 2 min read Vector setSize() method in Java with Example The Java.util.Vector.setSize() is a method of Vector class that is used to set the new size of the vector. If the new size of the vector is greater than the current size then null elements are added to the vector is new size is less than the current size then all higher-order elements are deleted. T 3 min read Vector size() Method in Java The java.util.vector.size() method in Java is used to get the size of the Vector or the number of elements present in the Vector. Syntax: Vector.size() Parameters: The method does not take any parameter. Return Value: The method returns the size or the number of elements present in the Vector. Below 2 min read Like