Play Games

Search This Blog

Friday, September 24, 2021

How to convert comma separated string to a list in apex - Salesforce Globe For You

How to convert comma separated string to a list in apex - Salesforce Globe For You

Problem: I have a string as a;b;c;d.and I want to convert that string value to array as new List<String>{'a','b','c','d'}

Sample Code:

String s = 'a;b;c;d';

List<String> lstAlphabet = new List<String>();

lstAlphabet = s.split(';');

System.debug('List is:::'+lstAlphabet);

Output:



No comments:

Post a Comment