
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java - String toLowerCase() Method
The Java String toLowerCase() method is used to convert all the characters of the given string into lowercase letters.
This method has two polymorphic variants; one without any arguments and, the other uses the criteria outlined by the given Locale data type to convert the string into lowercase. The syntaxes of these methods are given below.
Note: Keep in mind that case mapping is based on the Unicode Standard Version of Character class standard. Since the case mappings are not necessarily 1:1, the length of the new string that is produced may or may not match that of the original String.
Syntax
Following is the syntax for Java String toLowerCase() method −
public String toLowerCase() or, public String toLowerCase(Locale locale)
Parameters
locale − use the case transformation rules for this locale. // second syntax
Return Value
This method returns the String, converted to lowercase.
Converting a String to LowerCase Example
The following example shows the usage of Java String toLowerCase() method by converting the given characters of the string into its lower case letters without passing any arguments −
package com.turialspoint; public class StringDemo { public static void main(String[] args) { // converts all upper case letters in to lower case letters String str1 = "Self Learning Center"; System.out.println("string value = " + str1.toLowerCase()); str1 = "www.photofuntoos.com"; System.out.println("string value = " + str1.toLowerCase()); } }
Output
If you compile and run the above program, it will produce the following result −
string value = self learning center string value = www.photofuntoos.com
Converting a String to LowerCase Using Locale Example
Below is an example to convert the characters in a string to lower case by passing the Locale value to the toLowerCase() method −
package com.turialspoint; import java.util.Locale; public class StringDemo { public static void main(String[] args) { String str1 = "Self Learning Center"; // using the default system Locale Locale defloc = Locale.getDefault(); // converts all upper case letters in to lower case letters System.out.println("string value = " + str1.toLowerCase(defloc)); str1 = "WWW.PHOTOFUNTOOS.COM"; System.out.println("string value = " + str1.toLowerCase(defloc)); } }
Output
If you compile and run the program above, the output will be displayed as follows −
string value = self learning center string value = www.photofuntoos.com
Converting a String containing non-alphabetical characters to LowerCase Example
Let's create another code that will generate a string of characters that includes letters, numerals, and symbols. In this program, we will determine whether or not the toLowerCase() method affects non-alphabetical characters like numbers and symbols −
package com.turialspoint; public class StringDemo { public static void main(String[] args) { String s = "Welcome to @!! Tutorials point 77!!"; System.out.println("The given string is: " + s); String toLower = s.toLowerCase(); System.out.println("String after conversion is: " + toLower); } }
Output
On executing the program above, the output is obtained as follows −
The given string is: Welcome to @!! Tutorials point 77!! String after conversion is: welcome to @!! tutorials point 77!!
Converting a String to LowerCase Using Locale Example
In the example given below we are creating a program that converts the string "Welcome to turialspoint" into lowercase English letters by passing locale argument −
package com.turialspoint; import java.util.Locale; public class StringDemo { public static void main(String[] args) { String s = new String("Welcome to turialspoint"); System.out.println("The given string is: " + s); // Create Locale "Eng" for english. Locale English = Locale.forLanguageTag("Eng"); System.out.println("Lowercase letters in english: " + s.toLowerCase(English)); } }
Output
The output of the above program is as follows −
The given string is: Welcome to turialspoint Lowercase letters in spanish: welcome to turialspoint Lowercase letters in english: welcome to turialspoint