Convert Vector to Array
Object[] toArray()
- Returns an array containing all of the elements in this Vector in the correct order.
<T> T[] toArray(T[] a)
- Returns an array containing all of the elements in this Vector in the correct order; the runtime type of the returned array is that of the specified array.
String toString()
- Returns a string representation of this Vector, containing the String representation of each element.
import java.util.Arrays;
import java.util.Vector;
public class Main{
public static void main(String args[]) {
Vector v = new Vector();
v.add("java2s.com");
v.add("A");
v.add("B");
Object[] arr = v.toArray();
System.out.println(Arrays.toString(arr));
}
}
The output:
[java2s.com, A, B]
Home
Java Book
Collection
Java Book
Collection
Vector:
- Vector class
- Create Vector objects
- Add elements to this vector
- Size and capacity
- Remove all elements from a vector
- Clone a vector
- Does it contain a certain element
- Copy elements in vector to an array
- Get Enumeration from this vector
- Compare two vectors
- Get element from vector
- Is vector empty
- Get element index
- Remove element from a vector
- Retain elements collection c has
- Replace element in a vector
- Get a sub list from a list
- Convert Vector to Array