Java String toLowerCase() Method




Java String toLowerCase() method is used to convert a String into lowercase.All characters of a String are converted into lowercase characters.

There are two variants of toLowerCase() method:

I.) String java.lang.String.toLowerCase()

This method coverts a String into lowercase according to default locale which is en_IN.

II.) String java.lang.String.toLowerCase(Locale locale)

This method coverts a String into lowercase according to the rules of the locale which is passes as an argument in the method.

Let’s take an example to illustrate toLowerCase() method.

Example : Java String toLowerCase() Method

package com.masterjavatutorial;
import java.util.Locale;
public class Test {
	public static void main(String[] args) {
		String str = "I am HelloWorld";
		String lowerCase  = str.toLowerCase(); 
		System.out.println(lowerCase);
		
		Locale locale = Locale.FRANCE; 
		String lowercase1 = str.toLowerCase(locale);
		System.out.println(lowercase1); 
	}
}

Output of the above program is as below:

i am helloworld
i am helloworld

In this output is same for both variants of toLowerCase() method but it can differ in other cases.