EN
Java - combine multiple lists
5
points
In this short article we would like to show how to combine multiple lists into one list in Java.
Quick solution:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Example {
public static void main(String[] args) {
List<String> a = Arrays.asList("a", "aa");
List<String> b = Arrays.asList("b", "bb");
List<String> c = Arrays.asList("c", "cc");
List<String> combinedLists = new ArrayList<>();
combinedLists.addAll(a);
combinedLists.addAll(b);
combinedLists.addAll(c);
System.out.println(combinedLists.toString()); // [a, aa, b, bb, c, cc]
}
}