Home Java Java-conversion Convert Vector to Array



Convert Vector to Array
Posted on: August 6, 2007 at 12:00 AM
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.*;
import java.io.*;

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;
  }
  System.out.print(v);
  }
}

Output of the program:

C:\unique>javac VectorToArr.java

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

Download this example.

Related Tags for Convert Vector to Array:
javacarrayconvertlanguagevectorhelpgetthisaddprogramtoramlanerteulinconvertingmpsddjadageprotorwhichsctorkisharaygetsarrtvassthavctoprndonogro


More Tutorials from this section

Ask Questions?    Discuss: Convert Vector to Array  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.