Related Examples
  1. Vector class toString() method example
  2. Vector class toArray() method example
  3. Vector class subList(int fromIndex, int toIndex) method example
  4. Vector class size() method example
  5. Vector class setSize(int newSize) method example
  6. Vector class setElementAt(E obj, int index) method example
  7. Vector class set(int index, E element) method example
  8. Vector class retainAll(Collection c) method example
  9. Vector class removeElementAt(int index) method example
  10. Vector class removeElement(Object obj) method example
  11. Vector class removeAllElements() method example
  12. Vector class removeAll(Collection c) method example
  13. Vector class remove(Object o)method example
  14. Vector class remove(int index) method example
  15. Vector class lastIndexOf(Object o)method example
  16. Vector class lastElement() method example
  17. Vector class isEmpty()method example
  18. Vector class insertElementAt(E obj, int index)method example
  19. Vector class indexOf(Object o, int index)method example
  20. Vector class indexOf(Object o)method example
  21. Vector class hashCode()method example
  22. Vector class get(int index)method example
  23. Vector class firstElement()method example
  24. Vector class equals(Object o) method example
  25. Vector class ensureCapacity(int minCapacity)method example
  26. Vector class elements() method example
  27. Vector class copyInto(Object[] anArray)method example
  28. Vector class containsAll(Collection c)method example
  29. Vector class contains(Object o)method example
  30. Vector class clone()method example
  31. Vector class clear()method example
  32. Vector class capacity()method example
  33. Vector class addElement(E obj)method example
  34. Vector class addAll(int index, Collection c)method example
  35. Vector class addAll(Collection c)method example
  36. Vector class add(int index, E element) method example
  37. Vector class add(E e)method example
  38. Vector class trimToSize() method example
  39. Java Class Vector, Java Vector Methods, Java Vector Functions,Vector Examples Java

View All Examples
 

Vector class toString() method example

Returns a string representation of this Vector, containing the String representation of each element.


Vector class toString() method example. This example shows you how to use toString() method.This method Returns a string representation of this Vector, containing the String representation of each element.

Here is the code:-
/* 
 * @Program that Returns a string representation of this Vector, containing the 
String representation of each element.
 * ToString.java 
 * Author:-RoseIndia Team
 * Date:-26-May-2008
 */

import java.util.*;

public class ToString {

    public static void main(String[] args) {
//Creating Vector    
        Vector v = new Vector();
//Adding elements in the vector
        v.add("G");
        v.add("I");
        v.add("R");
        v.add("I");
        v.add("S");
        v.add("H");
//Returns a string representation of this Vector, containing the String 
//representation of each element.
        String s = v.toString();
        System.out.println("Elements of the String are: ");
//Displaying the element stored in the String
        System.out.println(s);
    }
}

Output of the program:-
Elements of the String are:
[G, I, R, I, S, H]

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US