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 list)
join
String str = "";
for (int i = 0; i < list.size(); i++) {
    if (i > 0) {
        str += ",";
    str += "'" + list.get(i) + "'";
return str;
...
Stringjoin(List list, String conjunction)
join
StringBuilder sb = new StringBuilder();
if (conjunction == null) {
    conjunction = ", ";
if (list != null && !list.isEmpty()) {
    for (String string : list) {
        sb.append(string).append(conjunction);
    sb.setLength(sb.length() - conjunction.length());
return sb.toString();
Stringjoin(List list, String delim)
Join each string in the string list list to one string that delimiter by given delimiter delim.
if ((list == null) || (list.size() < 1)) {
    return null;
StringBuffer buf = new StringBuffer();
Iterator<String> i = list.iterator();
while (i.hasNext()) {
    buf.append((String) i.next());
    if (i.hasNext()) {
...
Stringjoin(List list, String delim)
Returns the concatenation of strings from a list using the delimiter indicated.
boolean isDelimiter = false;
final StringBuilder builder = new StringBuilder();
if (list != null) {
    for (String val : list) {
        if (isDelimiter) {
            builder.append(delim);
        builder.append(val);
...
Stringjoin(List list, String delimiter)
join
StringBuilder sb = new StringBuilder();
int size = list.size();
for (int i = 0; i < size; i++) {
    sb.append(list.get(i)).append(i < size - 1 ? delimiter : "");
return sb.toString();
Stringjoin(List list, String delimiter)
join
return join(list, delimiter, "");
Stringjoin(List list, String delimiter)
This method joins together a list of Strings and separates them by a delimiter
StringBuffer buf = new StringBuffer("");
if (list != null && list.size() > 0)
    for (int i = 0; i < list.size(); i++)
        if (i == 0)
            buf.append(list.get(i));
        else
            buf.append(delimiter).append(list.get(i));
return buf.toString();
...
Stringjoin(List list, String sep)
This function is used to join all elements from a List list of String strings in only one String .
if (list.size() == 1) {
    return list.remove(0);
} else {
    return list.remove(0) + sep + join(list, sep);
Stringjoin(List list, String separator)
join
String joined = "";
for (String s : list) {
    joined += s + separator;
joined = !list.isEmpty() ? joined.substring(0, joined.length() - separator.length()) : joined;
return joined;
Stringjoin(List list, String separator)
join
if (list == null) {
    return null;
if (list.isEmpty()) {
    return "";
if (separator == null) { 
    separator = "";
...