Home >Java >javaTutorial >How to use tolowercase in java
The toLowerCase() method in Java converts the characters in the string to lowercase: returns a new string containing all lowercase characters. The original string is not changed. Affected by the locale, different locales may have different conversion rules.
Detailed explanation of toLowerCase() usage in Java
Introduction
toLowerCase() Method is an instance method of the String class in Java and is used to convert all characters in the string to lowercase.
Syntaxpublic String toLowerCase()
Return type
Returns a new String object , which contains all lowercase characters.
Parameters
This method does not accept any parameters.
Usage
Using the toLowerCase() method is very simple, just call this method on the String object. For example:
<code class="java">String str = "Hello, World!"; String lowercaseStr = str.toLowerCase();</code>
In the above example, the value of lowercaseStr is "hello, world!".
Note
Example
<code class="java">// 将 "JAVATPOINT" 转换为小写 String str1 = "JAVATPOINT".toLowerCase(); System.out.println(str1); // 输出:javatpoint // 将 "Hello, world!" 转换为小写 String str2 = "Hello, world!".toLowerCase(); System.out.println(str2); // 输出:hello, world!</code>
The above is the detailed content of How to use tolowercase in java. For more information, please follow other related articles on the PHP Chinese website!