import java.util.ArrayList; import java.util.List; public class Example { public static void main(String[] args) { // create two lists ListIn this example, we create two List objects and add elements to both of them. We then use the addAll() method to add all the elements of list2 to the end of list1. Finally, we print the new list that contains all the elements of both lists. The java.io List addAll() method is part of the java.util package library.list1 = new ArrayList<>(); List list2 = new ArrayList<>(); // add elements to list1 list1.add(1); list1.add(2); list1.add(3); // add elements to list2 list2.add(4); list2.add(5); list2.add(6); // append list2 to list1 list1.addAll(list2); // print the new list System.out.println(list1); } }