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 values, String delimiter)
Join a given List of String s, separated by a given delimiter.
StringBuilder sb = new StringBuilder();
if (values != null && !values.isEmpty()) {
    sb.append(values.get(0));
    for (int i = 1; i < values.size(); i++) {
        sb.append(delimiter);
        sb.append(values.get(i));
return sb.toString();
Stringjoin(List values, String string)
join
StringBuilder sb = new StringBuilder();
int c = values.size();
for (String val : values) {
    if (c-- > 1)
        sb.append(val + string);
    else
        sb.append(val);
return sb.toString();
Stringjoin(List words, String separator)
Joins a list of words together, separated by a separator string.
StringBuilder s = new StringBuilder();
for (String w : words) {
    if (s.length() > 0) {
        s.append(separator);
    s.append(w);
return s.toString();
...
Stringjoin(List entries, String separator)
join
if (entries == null) {
    return null;
StringBuilder output = new StringBuilder();
Iterator<T> iterEntries = entries.iterator();
while (iterEntries.hasNext()) {
    T entry = iterEntries.next();
    if (entry != null) {
...
Stringjoin(List list, String delim)
join
StringBuilder stBld = new StringBuilder();
for (T obj : list) {
    stBld.append(obj).append(delim);
return stBld.substring(0, stBld.length() - 1);
Stringjoin(List list, String delim)
join
String joined = null;
if (list.size() == 1) {
    joined = list.get(0).toString();
} else {
    StringBuilder stBld = new StringBuilder();
    for (T obj : list) {
        stBld.append(obj).append(delim);
    joined = stBld.substring(0, stBld.length() - 1);
return joined;
Stringjoin(List list, String delimiter)
Create a string out of the list's elements using the given delimiter.
if (list.isEmpty()) {
    return "";
final StringBuilder sb = new StringBuilder();
for (T element : list) {
    sb.append(element);
    sb.append(delimiter);
sb.delete(sb.length() - delimiter.length(), sb.length());
return sb.toString();
Stringjoin(List list, String joiner)
Join the list with joiner.
StringBuilder stringBuilder = new StringBuilder();
if (list == null) {
    return null;
if (list.isEmpty()) {
    return "";
for (T s : list) {
...
Stringjoin(List list, String separator)
Join list elements into a string.
StringBuffer result = new StringBuffer();
Iterator<T> iter = list.iterator();
while (iter.hasNext()) {
    result.append(iter.next());
    if (iter.hasNext()) {
        result.append(separator);
return result.toString();
Stringjoin(List objects, String separator)
join
StringBuilder result = new StringBuilder();
for (int i = 0; i < objects.size(); i++) {
    if (i > 0) {
        result.append(separator);
    result.append(objects.get(i).toString());
return result.toString();
...