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(String joinString, List strings)
join
StringBuilder sb = new StringBuilder();
for (int i = 0; i < strings.size(); ++i) {
    sb.append(strings.get(i));
    if (i + 1 < strings.size()) {
        sb.append(joinString);
return sb.toString();
...
Stringjoin(String joint, List elements)
Join all elements as a whole string, using 'joint' to separate each element
StringBuilder sb = new StringBuilder();
for (String ele : elements) {
    if (sb.length() != 0)
        sb.append(joint);
    sb.append(ele);
return sb.toString();
Stringjoin(String sep, List a)
join
return join(sep, a.toArray(new String[0]));
Stringjoin(String separator, Collection list)
join
return join(separator, null, null, list);
Stringjoin(String separator, Collection inputList)
Join the strings contained in inputList with the separator.
Iterator<String> itty = inputList.iterator();
return join(separator, itty);
Stringjoin(String separator, List items)
join
return join(separator, items.toArray(new Object[items.size()]));
Stringjoin(String separator, List objs)
Join a list of Strings with a separator.
if (objs == null) {
    throw new IllegalArgumentException("objs is null");
if (objs.isEmpty()) {
    return EMPTY_STRING;
Iterator<? extends Object> i = objs.iterator();
StringBuilder r = new StringBuilder(i.next().toString());
...
Stringjoin(String separator, List elements)
Returns a string containing all elements concatenated by a specified separator.
if (elements == null || elements.size() == 0) {
    return ""; 
StringBuffer sb = new StringBuffer(elements.size() * 3);
int i = 0;
for (Object elem : elements) {
    if (i++ > 0) {
        sb.append(separator);
...
Stringjoin(String separator, List items)
Returns a string containing the string representation of each item in the given list, separated by the given separator.
assert separator != null;
assert items != null;
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object item : items) {
    if (!first) {
        sb.append(separator);
    sb.append(item);
    first = false;
return sb.toString();
Stringjoin(String separator, List parts)
join
StringBuilder stringBuilder = new StringBuilder();
Iterator<String> iterator = parts.iterator();
while (iterator.hasNext()) {
    stringBuilder.append(iterator.next());
    if (iterator.hasNext())
        stringBuilder.append(separator);
return stringBuilder.toString();
...