Java Utililty Methods Collection Join

List of utility methods to do Collection Join

Description

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

Method

Stringjoin(Collection coll, String delimiter)
Returns the joined string.
StringBuilder buff = new StringBuilder();
for (String str : coll) {
    if (buff.length() > 0) {
        buff.append(delimiter);
    buff.append(str);
return buff.toString();
...
Stringjoin(Collection collection)
join
return join(collection, ", ");
Stringjoin(Collection collection)
join
if (collection != null && collection.size() != 0) {
    StringBuffer sb = new StringBuffer();
    for (String item : collection) {
        sb.append(item);
    return sb.toString();
return null;
...
Stringjoin(Collection collection, String separator)
Joins the collection of strings into a single string using the specified string as a separator.
StringBuilder sb = new StringBuilder();
Iterator<String> it = collection.iterator();
while (it.hasNext()) {
    sb.append(it.next());
    if (it.hasNext()) {
        sb.append(separator);
return sb.toString();
Stringjoin(Collection collection, String separator)
join
String constructed = "";
if (collection.isEmpty()) {
    return constructed;
for (String item : collection) {
    constructed += item + separator;
return constructed.substring(0, constructed.length() - separator.length());
...
Stringjoin(Collection collection, String separator)
Joins strings with the separator.
if (collection == null) {
    throw new NullPointerException("The collection parameter is null.");
if (separator == null) {
    throw new NullPointerException("The separator parameter is null.");
StringBuilder buf = new StringBuilder();
for (String s : collection) {
...
Stringjoin(Collection collection, String separator)
join
if (collection == null)
    return null;
if (collection.isEmpty())
    return "";
StringBuilder sb = new StringBuilder();
for (String s : collection) {
    if (sb.length() != 0)
        sb.append(separator);
...
Stringjoin(Collection elements)
join
assert elements != null;
assert elements.isEmpty() == false;
return String.join(", ", elements); 
Stringjoin(Collection in, String joinS)
join
String ret = null;
for (String s : in) {
    if (ret == null)
        ret = s;
    else
        ret += joinS + s;
if (ret == null)
...
Stringjoin(Collection items)
join
String separator = ", ";
Iterator<String> iterator = items.iterator();
StringBuilder stringBuilder = new StringBuilder();
if (iterator.hasNext()) {
    stringBuilder.append(iterator.next());
    while (iterator.hasNext()) {
        stringBuilder.append(separator).append(iterator.next());
return stringBuilder.toString();