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(List strings, String separator)
Joins a list of strings.
int size = strings.size();
if (size == 0) {
    return ""; 
StringBuilder sb = new StringBuilder(strings.size() * strings.get(0).length());
int index = 0;
int lastIndex = size - 1;
for (String string : strings) {
...
Stringjoin(List strings, String separator)
join
StringBuilder sb = new StringBuilder();
for (Iterator<String> i = strings.iterator(); i.hasNext();) {
    sb.append(i.next()).append(i.hasNext() ? separator : "");
return sb.toString();
Stringjoin(List strings, String separator)
join
if (strings == null) {
    return "";
StringBuffer sb = new StringBuffer();
for (int i = 0, m = strings.size(); i < m; i++) {
    String string = strings.get(i);
    if (string == null) {
        string = "";
...
Stringjoin(List stringsToJoin, char delimiter)
Join the list of strings with the passed in delimiter.
if (stringsToJoin == null) {
    return null;
StringBuilder sb = new StringBuilder(stringsToJoin.size() * 30);
for (int i = 0; i < stringsToJoin.size(); i++) {
    if (i > 0) {
        sb.append(delimiter);
    addToBuilderAndEscapeDelimiter(stringsToJoin.get(i), delimiter, sb);
return sb.toString();
Stringjoin(List strList, char separator)
join
if (strList == null || strList.isEmpty())
    return "";
if (strList.size() == 1)
    return strList.get(0);
StringBuilder sb = new StringBuilder();
for (String s : strList) {
    if (sb.length() > 0)
        sb.append(separator);
...
Stringjoin(List strList, String sep)
Join a list of strings using a specified separator.
StringBuilder builder = new StringBuilder();
for (final Iterator<String> i = strList.iterator(); i.hasNext();) {
    final String s = i.next();
    builder.append(s);
    if (i.hasNext())
        builder.append(sep);
return builder.toString();
...
Stringjoin(List tokens, String sep)
join
StringBuilder result = new StringBuilder();
if (!tokens.isEmpty()) {
    result.append(tokens.get(0));
for (String token : tokens.subList(1, tokens.size())) {
    result.append(sep);
    result.append(token);
return result.toString();
Stringjoin(List tokens, String separator)
Joins the set of tokens in the provided list into a single string.
return (join(tokens, null, null, separator));
Stringjoin(List tokens, String separator)
Combine tokens with a specified separator.
StringBuilder sb = new StringBuilder();
if (tokens != null && separator != null) {
    for (String token : tokens) {
        if (sb.length() > 0) {
            sb.append(separator);
        sb.append(token);
return sb.toString();
Stringjoin(List values)
join
return join(values, ", ");