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:


2 comments:

  1. USER_DEBUG event is not showing up when executing the code in anonymous window

    ReplyDelete
    Replies
    1. Change the log levels. Check steps 1 and 2 from the below link
      http://www.infallibletechie.com/2018/12/soql-execution-time-using-developer.html

      Delete