How to Count the no of coma seprated values using Apex in Salesforce?

How to Count the no of coma seprated values using Apex in Salesforce?

Sample Code:

  1. String str = ‘a,b,c,d,e’;  
  2. system.debug( ‘Count is ‘ + str.split( ‘,’ ).size() );  



Output:


Leave a Reply