Java Merge Two Lists: addAll() Method Guide
You can use the addAll() method to add all elements of one list to another list, thus merging the two lists. For example:
List<String> list1 = new ArrayList<>();
list1.add("A");
list1.add("B");
List<String> list2 = new ArrayList<>();
list2.add("C");
list2.add("D");
list1.addAll(list2);
System.out.println(list1); // 输出 [A, B, C, D]