Java Utililty Methods Collection Concatenate

List of utility methods to do Collection Concatenate

Description

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

Method

Collectionconcat(Collection... collections)
concat
if (collections == null || collections.length == 0) {
    return Collections.emptyList();
if (collections.length == 1) {
    return collections[0];
return concat(Arrays.asList(collections));
Listconcat(final Collection... collections)
Concatenates all the given collections together (order is conserved).
final List<T> concatenation = new ArrayList<T>();
for (final Collection<T> collection : collections) {
    if (collection != null) {
        concatenation.addAll(collection);
return concatenation;
Listconcat(final Collection... collections)
concat
final List<T> concatenation = new ArrayList<T>();
for (final Collection<T> collection : collections) {
    if (collection != null) {
        concatenation.addAll(collection);
return concatenation;
Stringconcat(String separator, Collection args)
concat
StringBuilder sb = new StringBuilder();
for (Object arg : args) {
    sb.append(separator).append(arg);
if (sb.length() > 0) {
    sb.delete(0, separator.length());
return sb.toString();
...
String[]concat(String[] first, Collection second)
concat
String[] array = Arrays.copyOf(first, first.length + second.size());
Iterator<String> it = second.iterator();
for (int i = first.length; i < array.length; i++)
    array[i] = it.next();
return array;
StringconcatCollection(Collection collection)
Converts a collection of Strings into one long String.
StringBuilder sb = new StringBuilder(collection.size());
for (String s : collection) {
    sb.append(String.valueOf(s));
return sb.toString();
StringBuilderconcatElements(final Collection c, final String separator)
Joins the String representations of the elements of a given Collection using a given separator.
final StringBuilder builder = new StringBuilder();
if (c.isEmpty()) {
    return builder;
final Iterator<?> oIterator = c.iterator();
builder.append(oIterator.next());
while (oIterator.hasNext()) {
    builder.append(separator).append(oIterator.next());
...
Collectionconcatenate(Collection collections)
concatenate
ArrayList concatenation = new ArrayList();
for (Iterator i = collections.iterator(); i.hasNext();) {
    Collection collection = (Collection) i.next();
    concatenation.addAll(collection);
return concatenation;
Stringconcatenate(Collection coll)
concatenate
StringBuilder sb = new StringBuilder();
Iterator<?> it = coll.iterator();
while (it.hasNext()) {
    sb.append(it.next());
    if (it.hasNext()) {
        sb.append(' ');
return sb.toString();
Stringconcatenate(Collection list)
concatenate
return concatenate(list, DEFAULT_DELIMITER);