The java.util.vector.copyInto() method is used to copy all of the components from this vector to another array, having enough space to hold all of the components of the vector. It is to be noted that the index of the elements remains unchanged. The elements present in the array are replaced by the elements of the vector.
Parameters: The parameter array is of the type of vector. This is the array into which the elements of the vector are to be copied.
Return Value: The method is of void type and does not return any values.
Exception: The method throws NullPointerException if the array is NULL.
Below programs illustrates the Java.util.Vector.copyInto() method:
Vector: [Welcome, To, Geeks, 4, Geeks] The initial array is: Hello World null null null null The final array is: Welcome To Geeks 4 Geeks null
Vector: [10, 20, 30, 40, 50] The initial array is: 50 60 70 80 90 null The final array is: 10 20 30 40 50 null
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.