8:42 pm - Monday June 26, 2017

Vector Example Program for copyInto(Object[] anArray)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

// Vector Example Program for copyInto(Object[] anArray)
/**
@author: candidjava.com
@description: This program copies the content of the vector into the Array
*/

import java.util.*;

public class CopyInto {
public static void main(String[] args) {
Vector v = new Vector(); // Creating a new vector
// adding strings to the vector
v.add("are");
v.add("u");
v.add("thr");
System.out.println(v);

String[] a = new String[3]; // creating a new string array
v.copyInto(a); // copying the contents of vector into array
for (String s : a) // printing the string array
{
System.out.println(s);
}
}
}


output:
[are, u, thr]
are
u
thr

Filed in: Z-A All Java Codes

Comments are closed.