Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining 2 Vectors into 1

Status
Not open for further replies.

ob1kanobee

Programmer
Dec 27, 2002
47
0
0
US
Hi,

I have 2 Vectors with the exact same structure that I want to combine into one.
Currently, I'm looping through first and second vector with a method that returns a list with both vectors' values.
Is there an easier way of doing this?
 
Vector: addAll (Collection c)
Code:
 Vector<Integer> v1 = new Vector<Integer> ();
Vector<Integer> v2 = new Vector<Integer> ();
Vector<Integer> v3 = new Vector<Integer> ();

for (int i = 0; i < 10; ++i)
{
	v1.add (new Integer (i));
	v2.add (new Integer (i));
}
v3.addAll (v1);
v3.addAll (v2);

for (Integer i : v3)
	System.out.print (i + " ");
System.out.println ();

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top