+ Start a Discussion
Gourav JainGourav Jain 

Compare 2 string arrays

I have 2 strings contating words separated by comma.
I want to compare the two strings.
Example:
String1={sfdc,developer,star,Apex};
String2={software Developer,Java,cloud,apex};
can anyone hepl me doing this.

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Try the below code snippet as reference:

String1={sfdc,developer,star,Apex};
String2={software Developer,Java,cloud,apex};

String[] st = String1.split(' , ');


for(integer i = 0; i<st.size(); i++)
{
if(String2.contains(string.valueof(st[i])))
{

}
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.