1//You can user the WordUtils class from apache commons-text library
2WordUtils.capitalize(str)
1String str = "hello world!";
2
3// capitalize first letter
4String output = str.substring(0, 1).toUpperCase() + str.substring(1);
5
6// print the string
7System.out.println(output);
8// Hello world!
9
1String str = "java";
2String cap = str.substring(0, 1).toUpperCase() + str.substring(1);
1import org.apache.commons.text.WordUtils;
2
3public class WordUtilsCapitalizeFullyExample {
4 public static void main(String[] args) {
5 String result1 = WordUtils.capitalizeFully("how to CAPITALIZE first letter words");
6 System.out.println(result1);
7 }
8}