3:06 pm - Tuesday September 26, 3161

Vector Example Program for addAll(Collection c)

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
/**
@author:candidjava.com
@description:Vector example program for addAll(Collection c)
 */

import java.util.Vector;

public class AddAll {
	public static void main(String args[]) {
		// create two objects of the vector
		Vector<Integer> vc = new Vector<Integer>();
		Vector<Integer> vc1 = new Vector<Integer>();
		// use add() method to add elements in the vc1
		vc1.add(11);
		vc1.add(22);
		vc1.add(33);
		// use add() method to add elements in the vc
		vc.add(111);
		vc.add(55);
		vc.add(85);
		// use addAll() method to add vc1 with vc
		vc.addAll(vc1);
		// let us print all the elements avaliable in the firstvec
		System.out.println("AddedNumbers:");
		for (Integer value : vc) {
			System.out.println("the value is:" + value);
		}
	}
}

//OUTPUT

the value is:111
the value is:55
the value is:85
the value is:11
the value is:22
the value is:33

Filed in: Z-A All Java Codes

Comments are closed.