Activity Forums Salesforce® Discussions What is capitalize() method while working with String in Salesforce?

  • Kirandeep

    Member
    March 16, 2020 at 4:48 pm

    capitalize() is a predefined method to make first letter of a word capital.
    For example:-
    String name = 'chauhan';
    System.debug('Capitalize-' + name.capitalize());

  • Aditya

    Member
    March 17, 2020 at 12:53 pm

    Hi Anjali,
    capitalize() method returns the current String in which first letter changed to title case:
    Example: String s = 'hello maximillian';
    String s2 = s.capitalize();
    System.assertEquals('Hello maximillian', s2);

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos