I have a String array as follows

String [] toAddress = new String [] {'[email protected]','[email protected]','[email protected]'};

I would like to get the output as

'[email protected]','[email protected]','[email protected]'.

Could you please give some direction on how to achieve this?


1 Answer 1


You can use String#join to get the output you want:

String result = '\''+String.join(toAddress,'\',\'')+'\'';

This will result in a single string with quoted addresses.

  • Thank you it worked. If I would like to learn more on the string methods do you suggest sites other MDN site?
    – user28452
    Commented Feb 26, 2017 at 6:48
  • 2
    @user28452 If you are working with strings in Apex, the best reference would be the Apex Developers' Guide
    – martin
    Commented Feb 26, 2017 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .