3:56 am - Monday February 20, 2017

Vector Example Program for toArray()

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 ex0ample program for toArray()***/
/**
*@Author:CandidJava.com
*@Description:convert vector collection to Array
*/

import java.util.Vector;

public class VectorToArray {
public static void main(String args[]) {
Vector v = new Vector();
v.add("aaa");
v.add("bbb");
v.add("ccc");
v.add("ddd");
Object ob[] = v.toArray();// convert vector to Array object
System.out.println("elemets of Array");
for (int i = 0; i < v.size(); i++)// Displaying the element stored in
// object Array
{
System.out.println(ob[i]);// print array object
}
}
}

OUTPUT:
elements of array
aaa
bbb
ccc
ddd

Filed in: Z-A All Java Codes

Comments are closed.