Java how to merge collections

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

public class Lautturi {

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

output:

[3, 7, 15, 8, 1, 3, 5, 7]
Created Time:2017-09-18 15:34:55  Author:lautturi