Java merge multiple collections

Java merge multiple collections
/**
 * @author lautturi.com
 * Java example: how to combine multiple collections in java
 */
import java.util.*;
import java.util.stream.Stream;

public class Lautturi {

	public static void main(String[] args) {
		Collection<Integer> collectionA = new ArrayList<Integer>();
		collectionA.add(3);
		collectionA.add(7);
		collectionA.add(15);
		collectionA.add(8);
		
		Collection<Integer> collectionB = new ArrayList<Integer>();
		collectionB.add(1);
		collectionB.add(3);
		collectionB.add(5);
		collectionB.add(7);
		
		Collection<Integer> collectionC = new ArrayList<Integer>();
		collectionC.add(2);
		collectionC.add(4);
		collectionC.add(6);
		
		Stream<Integer> combinedStream = Stream.concat(
				Stream.concat(
						collectionA.stream(),
						collectionB.stream()
				),
				collectionC.stream()
		);
		
		System.out.println(Arrays.toString(combinedStream.toArray()));
		
	}
}
Source:‮ww‬w.lautturi.com

output:

[3, 7, 15, 8, 1, 3, 5, 7, 2, 4, 6]
Created Time:2017-09-18 15:37:45  Author:lautturi