java how to capitalize a string code example
Example 1: java method to capitalize first letter
String str = "java";
String cap = str.substring(0, 1).toUpperCase() + str.substring(1);
// cap = "Java"
Example 2: uppercase java
string s="hello";
s = Character.toUpperCase(s.charAt(0)) + s.substring(1);
The output will be: Hello