capitalize each word in string java
//You can user the WordUtils class from apache commons-text library
WordUtils.capitalize(str)
0
0
String str = "java";
String cap = str.substring(0, 1).toUpperCase() + str.substring(1);
Thank you!
0
0
4
2
import org.apache.commons.text.WordUtils;
public class WordUtilsCapitalizeFullyExample {
public static void main(String[] args) {
String result1 = WordUtils.capitalizeFully("how to CAPITALIZE first letter words");
System.out.println(result1);
}
}
Thank you!
2
0
3.5
2
String str = "hello world!";
// capitalize first letter
String output = str.substring(0, 1).toUpperCase() + str.substring(1);
// print the string
System.out.println(output);
// Hello world!
Thank you!
2
0
Are there any code examples left?
New code examples in category Java