Capitalize 1st letter in a String – Apex

Use “capitalize() “ to make first letter of a word as Capital.

Sample Code: Run the below piece of code in Apex execute of Workbench or Anonymous code on Dev Console

String str ='hello';
str= str.capitalize();
system.debug('Output String : '+str);

Output :

2 Thoughts to “Capitalize 1st letter in a String – Apex”

  1. Wayne Chung

    Is there method to make whole string as Capital in Apex? Thanks.

Leave a Comment