Java List Concatenate concatenate(List a, List b)

Here you can find the source of concatenate(List a, List b)

Description

The given lists are not modified.

License

Apache License

Declaration

static <T> List<T> concatenate(List<T> a, List<T> b) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.Collections;
import java.util.List;

public class Main {
    /** The given lists are not modified. */
    static <T> List<T> concatenate(List<T> a, List<T> b) {
        if (a.isEmpty()) {
            return b;
        }/*from ww w  .  j  a v  a  2  s  .c  o  m*/
        if (b.isEmpty()) {
            return a;
        }
        List<T> l = new ArrayList<>(a.size() + b.size());
        l.addAll(a);
        l.addAll(b);
        return Collections.unmodifiableList(l);
    }
}

Related

  1. concatenate(List list1, List list2)
  2. concatenate(List components)
  3. concatenate(List list)
  4. concatenate(List strings)
  5. concatenate(List xs)
  6. concatenate(List contents, String separator)
  7. concatenate(List... lists)
  8. concatenate(String[] selectors, List lessExtends)
  9. concatenateFileContent(List fileContents)

  10. HOME | Copyright © www.java2s.com 2016