Skip to main content Labre su futuro con Agentforce en TDX, en San Francisco, o en Salesforce+ los días 5 y 6 de marzo. Regístrese ahora.
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 respuestas
  1. 14 ene 2021, 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');

    }

    }

    }

Cargando
0/9000