Skip to main content 3 月 5 日~ 6 日にサンフランシスコで開催される TDX に会場で、または Salesforce+ から参加して、Agentforce で未来を築きましょう。今すぐ申し込む
Hi All,

I have to compare two string vales in apex whether they are same vales or not. Could anyone please help me.  

String str1 = Pay TV;AVOD;Basic TV;

String str2 = Basic TV;Pay TV;AVOD;

Thanks,

Anil Kumar
5 件の回答
  1. 2021年1月14日 18:22

    Hi anil Kumar,

    Please find the solution.

    public static void CompareString(){

    String str1 = 'Pay TV;AVOD;Basic TV;';

    String str2 = 'Basic TV;Pay TV;AVOD;';

    List<String> str1List = str1.split(';');

    List<String> str2List = str2.split(';');

    for(Integer i=0;i<str1List.size();i++){

    if(str2List.contains(str1List[i])){

    system.debug('Yes this word '+str1List[i]+' is contains in str2List');

    }

    }

    }

0/9000