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
jayamjayam 

convert set of strings to list of strings

 i want to convert the set <string> to list<string>

how can do i  this

 

           Thanks in advance

 

 

 

 

 

 

 

Pradeep_NavatarPradeep_Navatar

You can use addAll() method of List collection to create list from set.


Example:

Set<String> s=new Set<String>();
s.add('xxx');
s.add('yyy');

List<String> l=new List<String>();
l.addAll(s);

sfdcfoxsfdcfox

You can also use the list constructor if you want to create and initialize the list at the same time.

 

 

Set<String> setStrings = new Set<String>{'hello','world'};
List<String> listStrings = new List<String>(setStrings);