Change String [] to Vector <String>

How can I convert in the fastest way String[]in Vector<String>?

+3
source share
5 answers

Using the Arrays.asList array:

Vector<String> v = new Vector<String>(Arrays.asList(yourStringArray));

Resources:

+14
source
Vector v = new Vector( Arrays.asList(array) );
+1

:

Vector<String> strings = new Vector<String>( Arrays.asList(yourStringArray ) );

+1

Check out this example: http://www.java2s.com/Code/Java/Collections-Data-Structure/ConvertanArraytoaVector.htm

It will look like this:

    String[] arr = { "1", "2", "3", "4" };
    Vector<String> v = new Vector<String>(Arrays.asList(arr));
+1
source

Source: https://habr.com/ru/post/1764288/


All Articles