Here you can find the source of concat(T[] left, T[] right)
public static <T> T[] concat(T[] left, T[] right)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; public class Main { public static <T> T[] concat(T[] left, T[] right) { return list(chain(Arrays.asList(left), Arrays.asList(right))).toArray(left); }//from w w w. java 2 s . com public static <T> List<T> list(Iterable<T> input) { List<T> ret = new ArrayList<>(); for (T item : input) { ret.add(item); } return ret; } public static <T> List<T> list(T[] input) { return Arrays.asList(input); } public static <T> Iterable<T> chain(final Iterable<? extends T> it1, final Iterable<? extends T> it2) { return new Iterable<T>() { @Override public Iterator<T> iterator() { class MyIt implements Iterator<T> { private final Iterator<? extends T> i1; private final Iterator<? extends T> i2; public MyIt(Iterator<? extends T> i1, Iterator<? extends T> i2) { this.i1 = i1; this.i2 = i2; } @Override public boolean hasNext() { return i1.hasNext() || i2.hasNext(); } @Override public T next() { return i1.hasNext() ? i1.next() : i2.next(); } @Override public void remove() { throw new UnsupportedOperationException(); } } return new MyIt(it1.iterator(), it2.iterator()); } }; } }