toString(): This method is available in java.util.Vector class of Java.
Syntax:
String java.util.Vector.toString()
This method returns a string representation of this Vector, containing the String representation of each element.
Parameters: NA
Returns: a string representation of this collection.
Exceptions: NA
Approach
Java
import java.util.Vector;public class VectortoString {public static void main(String[] args) {Vector<String> vector = new Vector<>();vector.add("Hello");vector.add("Java");vector.add("C++");vector.add("Program");System.out.println(vector.toString());}}
Output:
[Hello, Java, C++, Program]
No comments:
Post a Comment