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

Home Java Java-conversion Convert Vector to Array

Related Tutorials


Share on Google+Share on Google+

Convert Vector to Array

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

Convert Vector to Array


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

Code Description:

This program helps you in converting Vector to an Array. Here we have taken a Vector v.add("Java, is, a, wonderful, language");   which gets converted to an Array.

import java.util.Arrays;
import java.util.Vector;
import java.util.*;

public class VectorToArr {
  public static void main(String[] args) {
  Vector<String> v = new Vector<String>();
  v.add("Java, is, a, wonderful, language")
  String[] strings =new String[v.size()];
  int i =0;
  for(String str : v) {
  strings[i++= str;

Output of the program:


C:\unique>java VectorToArr
[Java, is, a, wonderful, language]

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: August 6, 2007

Related Tutorials

Discuss: Convert Vector to Array  

Post your Comment

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