Best way to concatenate List of String objects? [duplicate]

Use one of the the StringUtils.join methods in Apache Commons Lang.

import org.apache.commons.lang3.StringUtils;

String result = StringUtils.join(list, ", ");

If you are fortunate enough to be using Java 8, then it’s even easier…just use String.join

String result = String.join(", ", list);

Leave a Comment