Capitalize a String In Salesforce Apex

The Apex String class offered by Salesforce includes a bunch of useful functions to manipulate String, in case you would like the first letter of your String to be in title case you can use the capitalize function.

Code sample of String capitalize function:

String firstName = 'orleando';
System.debug(firstName.capitalize());
// The output will be 'Orleando'

Subscribe to our newsletter to be aware of the next snippet, article, or video to be released.

author-avatar

About Orleando Dassi

I'm a Solutions Architect with 10 years of experience who is constantly learning while impacting the community by producing technical articles/videos, building projects, and conducting tech mentoring/coaching sessions. What describes me the most is my flexibility. Follow me on Twitter and LinkedIn.