Link to home
Start Free TrialLog in
Avatar of ane4ka
ane4ka

asked on

Comparinf values in array in java

hello,

How do I compare values within two array in java.

Let's say we have the following two lists od strings:

["a", "b", "d"]

["a", "b", "c", "e"]

There could be 3 conditions:

1.  Value could be in two arrays (ex. a,b)
2.  Value could be only in first aray (ex. d)
3.  Value could be only in second array. (ex. c,e)

I need to identify one of the three conditions for each value in both array.  How can I doi tprogramaticly in java.

Thanks in advance!
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Add each to a Set and then do retainAll , etc on them
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ane4ka
ane4ka

ASKER

I'm not that pI'm not that proficient in Java.  Can you please be more specific and give some code examples.

Thanks for the quick reponse.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial