Solved

Compare string content in 2 vectors

Posted on 2004-05-02
2
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 10974089
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
ID: 10974162
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

719 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