Skip to content

Convert first character of String to lowercase in Java example

Convert first character of String to lowercase in Java example shows how to make the first character of string lowercase in Java using various approaches.

How to convert the first character of String to lowercase in Java?

You can use any of the below given approaches to make the first character of the string lower case in Java.

1) Convert the first character of String to lower case using the Character class and a char array

Convert the String to a character array, make the first element of an array lowercase and finally create a string from modified char array as given below.

Output

2) Using the substring method

Output

We took the first character of the String, made it lowercase and then joined it with the rest of the String using the substring method.

3) Using the Character class and charAt method

Output

This approach is similar to the substring approach. We took the first character of the string using the charAt method, made it to lowercase using the toLowerCase method of the Character class and then joined it with the rest of the String.

4) Using the Apache Commons

Finally, if you are using the Apache Commons library, you can use the uncapitalize method of the StringUtils class to make the first character of string lower case as given below.

Output

This example is a part of the String in Java tutorial.

Please let me know your views in the comments section below.

About the author

Leave a Reply

Your email address will not be published.