Solved

Compare string content in 2 vectors

Posted on 2004-05-02
2
315 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate example for saving data 19 79
Better way to make a string with template variables in java 3 35
Is there a simpler dropbox system? 10 44
jmeter usage 4 38
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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

730 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