Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; public class ArrayListAddAllExample3 { ArrayList
letters = new ArrayList<>(); letters.add("A"); letters.add("B"); letters.add("C"); System.out.println(letters); // [A, B, C] ArrayList
namesStartWithA = new ArrayList<>(); namesStartWithA.add("Adel"); namesStartWithA.add("Ahmed"); namesStartWithA.add("Ali"); System.out.println(namesStartWithA); // [Adel, Ahmed, Ali] System.out.println(1, letters.addAll(namesStartWithA)); // true System.out.println(letters); // [A, Adel, Ahmed, Ali, B, C] }
Output