Saturday 10 May 2014

Vector : toString : get the String representation of vector

public synchronized String toString()
Returns a string representation of this Vector. 

import java.util.*;
class VectorToString{
 public static void main(String args[]){
  Vector<Integer> myVector = new Vector<> ();

  /* Add Elements to myVector */
  myVector.add(10);
  myVector.add(123);
  myVector.add(321);
  myVector.add(456);
  
  System.out.println(myVector.toString());
 }
}

Output
[10, 123, 321, 456]


 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment