
Explanation of Solution
Method to add all the elements from one collection to another collection:
Addall(collection C) is the method used to add all the elements from one collection to another. The elements may be added individually.
Sample Program:
//Java program to illustrate addAll(Collection c)
import java.util.ArrayList;
public class Sample
{
public static void main(String args[])
{
// Creating array list1
ArrayList<Integer> collect1 = new ArrayList<Integer>(5);
// Adding elements to the list1
collect1.add(12);
collect1.add(20);
collect1.add(45);
// prints all the elements available in array //list1
System.out.println("Printing list1:");
for (Integer number : collect1)
System...
Want to see the full answer?
Check out a sample textbook solution
Chapter 20 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,


