Android Utililty Methods Iterable Join

List of utility methods to do Iterable Join

Description

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

Method

Stringjoin(Iterable collection)
join collection to string, separator is #DEFAULT_JOIN_SEPARATOR
 join(null)      =   ""; join({})        =   ""; join({a,b})     =   "a,b"; 
return collection == null ? "" : TextUtils.join(
        DEFAULT_JOIN_SEPARATOR, collection);
Stringjoin(Iterable parts, String delimiter)
Join a strings Iterable into a single string.
StringBuilder builder = new StringBuilder();
for (String s : parts) {
    builder.append(s).append(delimiter);
if (builder.length() > 0) {
    return builder.substring(0,
            builder.length() - delimiter.length());
return EMPTY;
Stringjoin(Iterable strings)
make a comma seperated string out a passed list/set of strings
StringBuilder builder = new StringBuilder();
for (String s : strings) {
    builder.append(s).append(", ");
String result = builder.toString();
return result.substring(1, result.length() - 2);
Stringjoin(Iterable s, CharSequence delimiter)
join
int capacity = 0;
int delimLength = delimiter.length();
Iterator<? extends CharSequence> iter = s.iterator();
if (iter.hasNext()) {
    capacity += iter.next().length() + delimLength;
StringBuilder buffer = new StringBuilder(capacity);
iter = s.iterator();
...
Stringjoin(Iterable iterable)
join
StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for (T t : iterable) {
    if (!isFirst) {
        sb.append(",");
        isFirst = false;
    sb.append(t.toString());
...