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

StringBuilderjoinToStringBuilder(Collection collection, String separator)
Concatenates the Collection of Objects (converted to Strings using .toString()) into a StringBuilder using the separator as the delimiter.
if (collection == null) {
    return new StringBuilder();
StringBuilder result = new StringBuilder(collection.size() * 10);
boolean needjoin = false;
for (Object obj : collection) {
    if (needjoin) {
        result.append(separator);
...
StringjoinValues(Collection values, String separator)
join Values
StringBuilder builder = new StringBuilder();
boolean first = true;
for (String value : values) {
    if (!first) {
        builder.append(separator);
    } else {
        first = false;
    builder.append(value);
return builder.toString();
Stringroundjoin(Collection s, String delimiter)
roundjoin
StringBuffer buffer = new StringBuffer();
Iterator iter = s.iterator();
while (iter.hasNext()) {
    buffer.append(String.valueOf(Math.round(328.084 * ((Double) iter.next())) / 100.00));
    if (iter.hasNext()) {
        buffer.append(delimiter);
return buffer.toString();
StringstringJoin(Collection list, String delim)
string Join
StringBuilder sb = new StringBuilder();
for (Object s : list) {
    if (s == null) {
        continue;
    if (sb.length() > 0) {
        sb.append(delim);
    sb.append(s.toString());
return sb.toString();
StringstringJoin(java.util.Collection s, String delimiter)
string Join
StringBuilder builder = new StringBuilder();
java.util.Iterator<?> iter = s.iterator();
while (iter.hasNext()) {
    builder.append(iter.next());
    if (!iter.hasNext()) {
        break;
    builder.append(delimiter);
...