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 input, String sep)
to String
if (input.isEmpty())
    return "";
String result = input.get(0);
for (int i = 1; i < input.size(); i++) {
    result += sep + input.get(i);
return result;
StringtoString(List list)
Forms the StringList into a normal sentence with Spaces
return toString(list.toArray(new String[list.size()]));
StringtoString(List list)
to String
String result = "";
for (int i = 0; i < list.size(); i++) {
    if (list.size() == 2 && i == 1) {
        result += " and ";
    } else if (list.size() > 2 && i == list.size() - 1) {
        result += ", and ";
    } else if (i != 0) {
        result += ", ";
...
StringtoString(List list, String delimiter)
to String
String argumentString = "";
Iterator<String> iterator2 = list.iterator();
for (int i = 0; iterator2.hasNext(); i++) {
    String argument = iterator2.next();
    if (i > 0)
        argumentString += delimiter;
    argumentString += argument;
return argumentString;
StringtoString(List list, String split)
to String
StringBuffer sbuf = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
    if (i > 0) {
        sbuf.append(split);
    sbuf.append(list.get(i));
return sbuf.toString();
...
StringtoString(List strings)
to String
final String SEPARATOR = ",";
final StringBuilder stringBuilder = new StringBuilder();
for (final String string : strings) {
    if (stringBuilder.length() != 0) {
        stringBuilder.append(SEPARATOR).append(' ');
    stringBuilder.append(string);
return stringBuilder.toString();
StringtoString(List strings)
to String
if (strings.isEmpty()) {
    return null;
StringBuilder builder = new StringBuilder();
Iterator<String> iterator = strings.iterator();
while (iterator.hasNext()) {
    builder.append(iterator.next());
    if (iterator.hasNext()) {
...
StringtoString(List list)
Convert to string a list of T objects.
return list == null ? "null" : Arrays.toString(list.toArray());
StringtoString(List list)
to String
StringBuilder buf = new StringBuilder();
int k = -1;
for (T t : list) {
    if (++k > 0) {
        buf.append(", ");
    buf.append(t);
return buf.toString();
StringtoString(List list)
to String
StringBuilder stringBuilder = new StringBuilder();
if (list.size() == 1) {
    stringBuilder.append(list.get(0));
} else if (list.size() == 2) {
    stringBuilder.append(list.get(0) + " and " + list.get(1));
} else if (list.size() > 0) {
    stringBuilder.append(list.get(0));
    for (int i = 1; i < list.size() - 1; i++) {
...