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
sai krishna 267sai krishna 267 

acc.contact_Names__c=contactNames.subString(0,contactNames.length()-1); what is substring use in these step?

Best Answer chosen by sai krishna 267
Prashant Pandey07Prashant Pandey07
Returns a new String that begins with the character at the specified zero-based startIndex and extends to the character at endIndex - 1

In your case, you are populating account's contact name with very first string from contactNames and trimming the last character from returned string.  
For example 
String str = 'SLA-UPsdfdsfdsfG-4HR-4ON';
String res = str.substring(0, str.length()-1);
system.debug('Your String---'+res);

You will get the result like this SLA-UPsdfdsfdsfG-4HR-4O