Solved

Compare string content in 2 vectors

Posted on 2004-05-02
2
312 Views
Last Modified: 2006-11-17
Hi, exert.

I have 2 vectors with the same elements:

vector1 { ID, name, phone }
vector2 { ID, name, phone }

and 1 vector which conisists of both elementS from vector1 and vector2
vector3 {ID1, ID2, name, phone1, phone2}

I want to find if the element "name" in these vector1 and vector2 are equal
i.e.
if vector 1 contain an element:
ID[1],  name[Grace],  phone[12345]
and vector 2 also contain an element:
ID[4],  name[Grace],  phone[99999]

I will add a new element in vector3, i.e.
ID[1], ID[2], name[Grace],  phone[12345],  phone[99999].

Are there any function in vector can do these in an more effiecient way ?

Thanks

0
Comment
Question by:vincehon
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
Comment Utility
for (int i=0; i<3; i++)
{
   vector3.add(vector1.get(i));
   if (vector1.get(i).equals(vector2.get(i)))
   {
      vector3.add(vector2.get(i));
   }
}
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 47
strCopies  challenge 17 73
groovy example issue 10 64
Java asynchronous logging 4 31
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now