comparing vectors in java
iam having vector v1 and v2 of diff size,i need compare v1 and v2 and find unique records from them
you will have to write your own comparison routine to do that, I don't think there is in java that will automatically tell you that.
there are few things that come to mind,
1. first see if both vectors are of the same size.
2. then scan through both and compare each item at the same index.
3. You will have to know in advance that what is the type of each item in the vector so that you can compare correctly..
just my 0.001 cent
You can probably use Commons-Collections to do that.
Look at CollectionUtils.retainAll().
This assumes that your Vectors contain all the same type of object. If it's your own object, you should probably make sure you code its equals() method.
At least I'm pretty sure it will work with Vectors...
If not, maybe you can switch them to ArrayLists.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)