Java List to Array convertStringListToArray(List list)

Here you can find the source of convertStringListToArray(List list)

Description

convert String List To Array

License

Apache License

Declaration

public static String[] convertStringListToArray(List<String> list) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static String[] convertStringListToArray(List<String> list) {
        if (list == null) {
            return new String[0];
        }//from w w  w  . j a  v a  2 s  .  co m

        // create new String array
        String array[] = new String[list.size()];

        // iterate through list
        for (int i = 0; i < list.size(); i++) {
            // get string and set to array
            array[i] = list.get(i);
        }

        return array;
    }
}

Related

  1. asArrayList(T... a)
  2. asBooleanArray(List list)
  3. asByteArray(final List l)
  4. asClassArray(List> list)
  5. convertStringListToArray(List list)
  6. convertToArray(final List> list)
  7. convertToArray(List list)
  8. convertToArray(List args)
  9. listToArray(final List list)