java.util.Collections.addAll() MethodAdvertisements Previous Page Next Page DescriptionThe addAll(Collection<? super T>, T..) method is used to add all of the specified elements to the specified collection. DeclarationFollowing is the declaration for java.util.Collections.addAll() method. public static <T> boolean addAll(Collection<? super T> c, T.. a)Parameters
Return ValueThe method call returns 'true' if the collection changed as a result of the call Exception
ExampleThe following example shows the usage of java.util.Collections.addAll() Live Demo package com.tutorialspoint;
import java.util.*;
public class CollectionsDemo {
public static void main(String args[]) {
// create array list object
List arrlist = new ArrayList();
// populate the list
arrlist.add("A");
arrlist.add("B");
arrlist.add("C");
System.out.println("Initial collection value: "+arrlist);
// add values to this collection
boolean b = Collections.addAll(arrlist, "1","2","3");
System.out.println("Final collection value: "+arrlist);
}
}
Let us compile and run the above program, this will produce the following result. Initial collection value: [A, B, C] Final collection value: [A, B, C, 1, 2, 3]java_util_collections.htm Page Not Found× Home Jobs Tools Coding Ground Current Affairs UPSC Notes Online Tutors Whiteboard Tutorix Login Categories
Q/A Library eBooks Courses 404 - Page Not Found404We're sorry, but the page you were looking for doesn't exist. Here are some useful links
Extras Mobile FirstAbout us
Extra Links
Contact Us
© Copyright 2021. All Rights Reserved. go |