Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Java Java-conversion Convert Array to Vector

Related Tutorials


Share on Google+Share on Google+

Convert Array to Vector

In this section, you will learn to convert an Array to Vector.

Convert Array to Vector


In this section, you will learn to convert an Array to Vector. 

Code Description:

This program helps you in converting an Array into a Vector. Here we have taken an array of data which gets converted to data of Vector using Array.asList method. We have also used Enumeration to get the next element of the data.

import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
import java.util.*;

/** Convert an Array to a Vector. */
public class ArrToVector {
  public static void main(String[] args) {
  Object[] Greet = {"Tamana Aggrawal"new Date()};
  Vector<Object> v = new Vector<Object>(Arrays.asList(Greet));
  Enumeration e = v.elements();
  while (e.hasMoreElements()) {

Output of the program: 


C:\unique>java ArrToVector
Tamana Aggrawal

Mon Jul 30 17:32:03 GMT+05:30 2007


Download this example.


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 18, 2008

Related Tutorials

Discuss: Convert Array to Vector  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image