Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Appending Vectors

 
Stephen Murphy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to append one vector to the end of another? I was hoping there was a method already in java to do this. Otherwise I'll have to write one myself.

Thanks,
Stephen
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you examined the addAll() method?
 
Stephen Murphy
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was so amazingly obvious. Don't know how I missed a method that adds a collection.

Thanks.
 
sven studde
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>Is there a way to append one vector to the end of another?

Why are you using a Vector? You most likely should be using an ArrayList, which is just like an array, but it can grow in size. Vector = oldschool, ArrayList = newschool.
[ November 05, 2006: Message edited by: sven studde ]
 
Sudhakar Reddy Kurakula
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
This is the code.

Vector v1=new Vector();
//add elements.
Vector v2=new Vector();
v1.add(v2);
//now this appends at the end of the last element.

Cheers
Sudhakar Reddy
M.C.A(2006)
Satyam.
9989223696
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic