Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; public class ArrayListAddAllExample2 { ArrayList
fruits = new ArrayList<>(); fruits.add("Apple"); fruits.add("Banana"); fruits.add("Orange"); System.out.println(fruits); // [Apple, Banana, Orange] ArrayList
vegetables = null; fruits.addAll(vegetables); // throws NullPointerException }
Output