Java List to String asStringList(List coll)

Here you can find the source of asStringList(List coll)

Description

Returns a string list representation of the given list.

License

Open Source License

Parameter

Parameter Description
coll List to convert

Return

A list containing string representations for all elements of the input list.

Declaration

public static List<String> asStringList(List<?> coll) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**//from w ww .j a v  a  2s. c o m
     * Returns a string list representation of the given list.
     * 
     * @param coll
     *            List to convert
     * @return A list containing string representations for all elements of the
     *         input list.
     */
    public static List<String> asStringList(List<?> coll) {
        List<String> result = new ArrayList<>();
        for (Object t : coll) {
            result.add(t.toString());
        }
        return result;
    }

    public static String toString(List<?> coll, char delimiter) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < coll.size(); i++) {
            builder.append(coll.get(i));
            if (i < coll.size() - 1)
                builder.append(delimiter);
        }
        return builder.toString();
    }
}

Related

  1. asString(List list)
  2. asString(List commandLine)
  3. asStringList( Collection objects)
  4. asStringList(Collection list)
  5. asStringList(Collection objects)
  6. asStringList(Set attributes)
  7. convertListToStrArray(List list)
  8. convertListToString(Iterable l)
  9. convertListToString(List list)