Java List Create CreateStringList(Collection values)

Here you can find the source of CreateStringList(Collection values)

Description

Converts a generic collection of objects into a list of String objects.

License

Open Source License

Parameter

Parameter Description
values Collection of objects

Return

List of String objects

Declaration

public static ArrayList<String> CreateStringList(Collection<String> values) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

public class Main {
    /** Converts an array of String objects to a list of String objects.
     *//  w  ww.  ja v a  2 s. c  o m
     * @param values Array of String objects
     * @return List of String objects
     */
    public static ArrayList<String> CreateStringList(String... values) {
        ArrayList<String> results = new ArrayList<String>();
        if (values.length > 0)
            Collections.addAll(results, values);
        return results;
    }

    /** Converts a generic collection of objects into a list of String objects.
     *
     * @param values Collection of objects
     * @return List of String objects
     */
    public static ArrayList<String> CreateStringList(Collection<String> values) {
        ArrayList<String> results = new ArrayList<String>();

        for (Object value : values)
            results.add(String.valueOf(value));

        return results;
    }
}

Related

  1. createSourceExtensionList(Map sourceExtensionMap)
  2. createSpaceDelimitedString(List stringList)
  3. createStringDummyList()
  4. createStringFromIntArray( List listOfNumbers)
  5. createStringFromIntegerList(List lst)
  6. createStringList(String csvString)
  7. createStringList(String spaceDelimitedString)
  8. createStringListFromStringArr(String[] stringArr)
  9. createSubList(Collection source, Class type)