Java Utililty Methods List Join

List of utility methods to do List Join

Description

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

Method

Stringjoin(String separator, List parts)
join
if (parts.isEmpty()) {
    return "";
StringBuilder result = new StringBuilder();
result.append(parts.get(0));
for (int i = 1; i < parts.size(); i++) {
    result.append(separator).append(parts.get(i));
return result.toString();
Stringjoin(String separator, List parts)
join
StringBuilder result = new StringBuilder();
for (String part : parts) {
    if (!isNullOrEmpty(part)) {
        if (result.length() > 0) {
            result.append(separator);
        result.append(part);
return result.toString();
Stringjoin(String sign, List src)
join
StringBuilder builder = new StringBuilder();
if (src != null) {
    for (T string : src) {
        builder.append(string).append(sign);
    if (builder.lastIndexOf(sign) > 0) {
        builder.delete(builder.lastIndexOf(sign), builder.length());
return builder.toString();
Stringjoin(String[] elementList, String separator)
Join the given element list with the specified separator
StringBuffer b = new StringBuffer();
for (int i = 0; i < elementList.length - 1; i++) {
    b.append(elementList[i]);
    b.append(separator); 
b.append(elementList[elementList.length - 1]);
return b.toString();
Stringjoin(String[] list, String separator)
Join the elements of an array of strings with a separator.
return join(Arrays.asList(list), separator);
Stringjoin(T delimiter, List list)
join
StringBuilder sb = new StringBuilder();
if (list != null && !list.isEmpty()) {
    for (int i = 0; i < list.size(); i++) {
        sb.append(list.get(i));
        if (i <= list.size() - 1)
            sb.append(delimiter);
return sb.toString();
Listjoin(T element, List otherElements)
Joins all given elements in a single (flat) List.
final List<T> result = new ArrayList<>();
result.add(element);
result.addAll(otherElements);
return result;
StringjoinAndQuote(char joinChar, char quoteChar, List strings)
join And Quote
StringBuilder sb = new StringBuilder();
for (int i = 0; i < strings.size(); ++i) {
    sb.append(quoteChar);
    sb.append(strings.get(i));
    if (i + 1 < strings.size()) {
        sb.append(joinChar);
    sb.append(quoteChar);
...
StringjoinArray(List list, String separator)
Transforms list into a string.
StringBuilder result = new StringBuilder();
boolean first = true;
for (T element : list) {
    if (first) {
        first = false;
    } else {
        result.append(separator);
    result.append(element);
return result.toString();
StringjoinArrayString(List values)
join Array String
StringBuilder buffer = new StringBuilder("");
for (String value : values) {
    buffer.append(value);
return buffer.toString();