File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Adding 2 vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Adding 2 vectors" Watch "Adding 2 vectors" New topic

Adding 2 vectors

naidu rasagna

Joined: Apr 04, 2006
Posts: 15
I have 2 vectors and i have to place the content of 2 vectors in to another vector.
Vector v1= getting data from database and placing that in this
Vector v2= getting data from db
Vector v3 = new Vector();
But this is not working
Can any one plz help me
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
You need to use the addAll() method, to put the *content* of a Collection into a Vector. The add() method puts the Collection itself in.

Unless you are using legacy code that forces you to use Vector, you should never use Vector. Use ArrayList, LinkedList or some other modern implementation of List.

A bartender will shortly be complaining about your obviously-false display name. Do yourself a favour and put in a real (sounding) one, before they do.

Lastly, this is not an advanced issue. Wrong forum.
[ April 04, 2006: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
I agree. Here's the link:
subject: Adding 2 vectors
It's not a secret anymore!