Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use java to convert the first letter of a string to uppercase and all others to lowercase

Shulou Source: shulou.com Published: 2022-06-03 09:45:13 10月06日 Update

This article will explain in detail how to use java to convert the first letter of a string to uppercase and all others to lowercase. I think it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

The details are as follows:

Public class TestSubstring {public static void main (String [] args) {String s = getConvert ("adsJKJ3K21AfaAD134F13241d134134s141faAAFDF"); System.out.println (s);} / / converts the first letter of a string to uppercase and all others to lowercase public static String getConvert (String str) {String first = str.substring (0,1); String after = str.substring (1) / / substring (1) to get all the remaining strings first = first.toUpperCase (); after = after.toLowerCase (); return "converted string:" + first + after "after index position 1 / / Adsjkj3k21afaad134f13241d134134s141faaafdf}} about "how to use java to convert the first letter in a string to uppercase and all others to lowercase" this article ends here. I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Character string uppercase letter lowercase article and will more good practical location content article knowledge index remaining reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi Linux vpn MySQL