Java List to String asStringList( Collection objects)

Here you can find the source of asStringList( Collection objects)

Description

Returns a list of strings, where the strings are the result of calling String.valueOf( Object ) of each object in the given collection.

License

Open Source License

Parameter

Parameter Description
objects the collection of objects.

Return

a list of strings.

Declaration

public static List<String> asStringList(
        Collection<? extends Object> objects) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Main {
    /**/* w  w w  . j  a  v a  2s. c  o m*/
     * Returns a list of strings, where the strings are the result of calling
     * String.valueOf( Object ) of each object in the given collection.
     * 
     * @param objects the collection of objects.
     * @return a list of strings.
     */
    public static List<String> asStringList(
            Collection<? extends Object> objects) {
        List<String> list = new ArrayList<>();

        for (Object object : objects) {
            list.add(String.valueOf(object));
        }

        return list;
    }
}

Related

  1. asString(List list)
  2. asString(List commandLine)
  3. asStringList(Collection list)
  4. asStringList(Collection objects)
  5. asStringList(List coll)
  6. asStringList(Set attributes)