function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.