Java Utililty Methods List to String

List of utility methods to do List to String

Description

The list of methods to do List to String are organized into topic(s).

Method

StringtoString(List list)
to String
StringBuilder builder = new StringBuilder();
boolean first = true;
builder.append("[");
for (Object o : list) {
    if (first) {
        first = false;
    } else {
        builder.append(", ");
...
StringtoString(List list)
to String
if (list == null)
    return "null";
StringBuilder sb = new StringBuilder();
sb.append('[');
for (Object element : list) {
    sb.append(element);
    sb.append(',');
sb.setLength(sb.length() - 1);
sb.append(']');
return sb.toString();
StringtoString(List list, char sep)
to String
return toString(list, sep, DEFAULT_ESCAPE_CHAR);
StringtoString(List list, String separator)
Converts the given list to a String.
StringBuilder builder = new StringBuilder();
if (list.size() > 0) {
    builder.append(list.get(0));
for (int i = 1; i < list.size(); i++) {
    builder.append(separator);
    builder.append(list.get(i));
return builder.toString();
ListtoString(List objects)
to String
if (objects == null) {
    return Collections.emptyList();
List<String> result = new ArrayList<>(objects.size());
for (Object object : objects) {
    result.add(String.valueOf(object));
return result;
...
StringtoString(List c)
to String
if (c == null)
    return null;
final StringBuffer s = new StringBuffer(c.size());
for (int i = 0; i < c.size(); i++) {
    s.append(c.get(i));
return s.toString();
StringtoString(List list)
to String
StringBuffer buffer = new StringBuffer();
for (Character character : list) {
    buffer.append(character);
return buffer.toString();
ListtoString(List> classes)
Uses Class#getSimpleName() to convert from Class to String .
List<String> list = new ArrayList<>();
for (Class<?> aClass : classes) {
    list.add(aClass.getSimpleName());
return list;
StringBuildertoString(List> values)
to String
StringBuilder sb = new StringBuilder();
for (List<Double> list : values) {
    for (Double float1 : list) {
        sb.append(float1).append(";");
    sb.append("\n");
return sb;
...
ListtoString(List listOriginal)
Creates a new list that contains the string representations of all elements of the original list null values are preserved.
List<String> list = new ArrayList<String>();
Object elem;
for (int i = 0; i < listOriginal.size(); i++) {
    elem = listOriginal.get(i);
    if (elem != null) {
        list.add(String.valueOf(elem));
    } else {
        list.add(null);
...