Convert list to array.

@param v list of string
@return array of string, empty array if list null.
439089
private String[] safeListToArray(List<String> v)
   {
      return v != null ? v.toArray(new String[v.size()]) : new String[0];
   }
277237
public static <T> T[] toArray(Class<T> c, List<T> list)
  {
    @SuppressWarnings("unchecked")
    T[] ta= (T[])Array.newInstance(c, list.size());

    for (int i= 0; i<list.size(); i++)
      ta[i]= list.get(i);
    return ta;
  }
977615
@Nonnull
    public final ArrayList<A> toArrayList() {
        ArrayList<A> list = new ArrayList<>(this.length);
        ImmutableList<A> l = this;
        for (int i = 0; i < length; i++) {
            list.add(((NonEmptyImmutableList<A>) l).head);
            l = ((NonEmptyImmutableList<A>) l).tail;
        }
        return list;
    }
981439
private static int[] toIntArray(List<Integer> list) {
    if (list == null || list.isEmpty()) {
      return NO_BINDS;
    }
    int[] res = new int[list.size()];
    for (int i = 0; i < list.size(); i++) {
      res[i] = list.get(i); // must not be null
    }
    return res;
  }
1150585
private Object convertListToArray(Class pType, List pList) {
        Class valueType = pType.getComponentType();
        Object ret = Array.newInstance(valueType, pList.size());
        int i = 0;
        for (Object value : pList) {
            if (value == null) {
                if (!valueType.isPrimitive()) {
                    Array.set(ret,i++,null);
                } else {
                    throw new IllegalArgumentException("Cannot use a null value in an array of type " + valueType.getSimpleName());
                }
            } else {
                if (valueType.isAssignableFrom(value.getClass())) {
                    // Can be set directly
                    Array.set(ret,i++,value);
                } else {
                    // Try to convert from string
                    Array.set(ret,i++,convertFromString(valueType.getCanonicalName(), value.toString()));
                }
            }
        }
        return ret;
    }
215266
public static String[] objectArrayToStringArray(final Object[] objectArray) {
		if( objectArray == null ) {
			return null;
		}
		
		final String[] stringArray = new String[objectArray.length];
		for( int i = 0; i < objectArray.length; i++ ) {
			stringArray[i] = objectArray[i] != null ? objectArray[i].toString() : null;
		}
		
		return stringArray;
	}
963287
public Object[] toArray(List<?> list, Class<?> arrayType) {
        int[] dims = findArrayDimensions(list, arrayType);
        Object[] typedArray = (Object[]) Array.newInstance(arrayType, dims);
        return list.toArray(typedArray);
    }
529452
private Object[] _asArray(
                    final Object obj
                    )
    {
        Object[]  array = null;
        if (obj instanceof Object[]) {
            array = (Object[])obj;
            if (array.length == 0) {
                throw new IllegalArgumentException( "ERROR: empty array" );
            }
        } else {
            array = new Object[] { obj };
        }

        return array;
    }
408392
public static String[] toArray(Collection<String> stringCollection) {
        return JMOptional.getOptional(stringCollection).map(Collection::size)
                .map(String[]::new).map(stringCollection::toArray)
                .orElseGet(JMArrays::getEmptyStringArray);
    }
916237
@Nullable
    public static String[] nullableArrayOfStringsFromListOfStrings(@Nullable List<String> list) {
        return list == null || list.isEmpty()
                ? null
                : list.toArray(new String[list.size()]);
    }
121756
public function toArray()
    {
        if ($this->gettersVariable) {
            $var = $this->gettersVariable;

            return $this->{$var};
        }

        $properties = (array)$this;
        $list = [];
        foreach ($properties as $property => $value) {
            if ($property[0] !== "\0") {
                $list[$property] = $value;
            }
        }

        return $list;
    }
577306
public static String[] toStringArray(final Object array) {
        final int length = Array.getLength(array);
        final String[] result = new String[length];
        for (int i = 0; i < length; i++) {
            result[i] = Array.get(array, i).toString();
        }
        return result;
    }
730297
@SuppressWarnings("unchecked")
    public static Object[] toArray(final Collection<?> c) {
        if (N.isNullOrEmpty(c)) {
            return N.EMPTY_OBJECT_ARRAY;
        }

        return c.toArray(new Object[c.size()]);
    }
276598
public static Object[] toArray(Object obj)
	{
		if (obj instanceof Object[])
			return (Object[]) obj;
		else
		{
			Object[] returnArray =
			{ obj };
			return returnArray;

		}
	}
1255839
public List<String> getAsStrings() {
        if (this.isEmpty()) {
            return Collections.emptyList();
        } else {
            final List<String> toStringVals = new ArrayList<>(this.size());
            for (final T i : this) {
                toStringVals.add(i == null ? "null" : i.toString());
            }
            return toStringVals;
        }
    }
434471
private static int[] toIntArray(List<Integer> list) {
		int[] array = new int[list.size()];
		int i = 0;
		for (Integer intObj : list) {
			array[i++] = toInt(intObj);
		}
		return array;
	}
697348
public static String[] toStringArray(ArrayList<String> src) {
    String[] ret = new String[src.size()];
    return src.toArray(ret);
  }