Tuesday, 26 May 2015

How to Convert Array to Vector

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

public class ArrayToVector {

    public static void main(String[] args) {
      

        String [] arr ={"java","c","cpp","php","html"};
       
        Vector<String> vector = new Vector<String>(Arrays.asList(arr));

        for (String str : vector) {

            System.out.println("Element is = "+str);

        }

    }

}

 Output:

Element is = java

Element is = c

Element is = cpp

Element is = php

Element is = html



No comments:

Post a Comment