|
-
January 28th, 2011, 07:56 AM
#1
finding two matching strings
Hello,
I have four strings, string1, string2, string3 and string4. Two of these strings are equal, now I want to find out which are equal and put the result into two strings, e.g. result1="3" result2="4" if string 3 and 4 are equal. Of course I can do an if then else ladder
Code:
if(string1.equalsIgnoreCase(string2))
{
result1="1";
result2="2";
}
else if(string1.equalsIgnoreCase(string3))
{
result1="1";
result2="3";
}
//and so on
Is there a better way of doing this? result1 can be given as a string as above or as well as an integer if that makes it easier.
Having 4 strings the above code can handle it, but what if I have a 100 strings.
Thanks,
J.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|