Vector class copyInto(Object[] anArray)method example
Copies the components of this vector into the specified array.
Vector class copyInto(Object[] anArray)method example. This example shows you how to use copyInto(Object[] anArray)method.This method Copies the components of this vector into the specified array.
Here is the code:-
/*
* @Program that Copies the components of this vector into the specified array.
* CopyInto.java
* Author:-RoseIndia Team
* Date:-24-May-2008
*/
import java.util.*;
public class CopyInto {
public static void main(String[] args) {
//creating a vector
Vector v=new Vector();
v.add("Tikil");
v.add("Deepu");
v.add("Yogi");
v.add("Takilla");
//creating array
String[] Arr = new String[5];
//Copies the components of this vector into the specified array.
v.copyInto(Arr);
System.out.print("Elements in Array are : ");
for(int i=0;i<Arr.length;i++)
//displaying the components of array
System.out.print(Arr[i]+"\t");
}
} |
Output of the program:-
| Elements in Array are : Tikil Deepu Yogi Takilla null |
|