• Convert List Of Strings to Comma Separated String in Apex

    Published By: Venu Gutta
    Published on: Friday, 24 February 2023
    A- A+

    Apex Convert String List to Comma Separated String

    The String.join() method can be utilized to concatenate a list of strings with a specified separator. We can use commas, semi colons, and other separators.

    The following code generates a list of two strings, 'Rama', and 'Rao', and then concatenates two strings with a comma separator using the String.join() method. Using the System.debug() method, the resulting string 'Rama, Rao' is the output of the debug log result.

    Example code for Convert List Of Strings to Comma Separated String in Apex 

    
    List < String > stringList = new List < String > { 'Rama', 'Rao' };  
    String result = String.join( stringList, ', ' );  
    System.debug( 'result=======>' + result );
    

    Output for List Of Strings to Comma separator Separated String in Apex 




  • No Comment to " Convert List Of Strings to Comma Separated String in Apex "