3:35 pm - Sunday August 20, 2017

Insert a collection element in already excisting collection using AddAll()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

                     Public static <T>boolean addAll(collection<? super T>c,T…. element)

                                       addAll (collection c) is used to insert the specified collection element  in the already excited collection.

Example Program

import java.util.Collections;

import java.util.ArrayList;

public class collectionAddAll

{

	public static void main(String[] args)

	{

		List model = new ArrayList();

		model.add("1");

		model.add("2");

		System.out.println("The initial model value: " + model);

		boolean m = Collections.addAll(model, "3", "4", "5");

		System.out.println("the final model value:" + model);

	}

}

Output

   The initial model value: [1, 2]

   the final model value:[1, 2, 3, 4, 5]

 

BACK

Filed in: Java Material

Comments are closed.