Java Utililty Methods List Concatenate

List of utility methods to do List Concatenate

Description

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

Method

Listconcat(List lista, List listb)
concat
List<A> result = new ArrayList<>(lista);
result.addAll(listb);
return Collections.unmodifiableList(result);
Stringconcat(List items, String quotation, String separation)
concat
StringBuilder sb = new StringBuilder();
for (int i = 0; i < items.size(); i++) {
    sb.append(quotation + items.get(i) + quotation);
    if (i < items.size() - 1) {
        sb.append(separation);
return sb.toString();
...
Stringconcat(List items, String separator)
concat
StringBuilder sb = new StringBuilder();
for (String item : items) {
    sb.append(item).append(separator);
if (sb.length() > 0) {
    return sb.substring(0, sb.length() - separator.length());
} else {
    return null;
...
Stringconcat(List strings, String separator)
concat
StringBuilder sb = new StringBuilder();
String sep = "";
for (String s : strings) {
    sb.append(sep).append(s);
    sep = separator;
return sb.toString();
Stringconcat(List tokens)
concat
StringBuilder sb = new StringBuilder(tokens.size() * 10);
int size = tokens.size();
for (int i = 0; i < size; i++) {
    sb.append(tokens.get(i));
    if (i < size - 1) {
        sb.append(TOKEN_SEPARATER);
return sb.toString();
Stringconcat(List words)
concat
StringBuilder sb = new StringBuilder();
for (int i = 0; i < words.size(); i++)
    sb.append(i > 0 ? "@" : "").append(words.get(i));
return sb.toString();
String[]concat(List... lists)
concat
List<String> c = new ArrayList<String>();
for (List<String> l : lists) {
    c.addAll(l);
return c.toArray(new String[c.size()]);
voidconcat(List lista, String sep, StringBuilder destino)
concat
Iterator<StringBuilder> it = lista.iterator();
while (it.hasNext()) {
    destino.append(it.next());
    if (it.hasNext()) {
        destino.append(sep);
Listconcat(List a, List b)
Concatenates two lists to form a new list.
List<T> result = new ArrayList<>(a.size() + b.size());
result.addAll(a);
result.addAll(b);
return result;
Listconcat(List collection1, List collection2)
concat
if (isEmpty(collection1)) {
    return collection2;
if (isEmpty(collection2)) {
    return collection1;
collection1.addAll(collection2);
return collection1;
...