You can convert the whole string into lowercase by using the toLowerCase() method in Java. On this page, we have shared a few examples of this method.

Method signature:

The signature for a toLowerCase() method is as shown below.

public String toLowerCase()

public String toLowerCase(Locale locale)

Method parameters and return type:

Return type: It returns a string in lowercase letters.

Parameters: For the first signature, it doesn’t take any parameters. For the second signature, we pass the locale object as a parameter.

Throws: It throws a NullPointerException if the string is null.

Example 1:

Here we have converted a string into a lowercase.

Source code:

public class Example1 {

    public static void main(String args[]) {
        String str = "LEARN jAVA coDE";
        String toLower = str.toLowerCase();
        System.out.println(toLower);
    }
}

Output:

run:
learn java code
BUILD SUCCESSFUL (total time: 9 seconds)

Example 2:

You can also pass a locale as an argument for different languages in the method.

Source code:

public class Example2 {
    
    public static void main(String[] args) {  
        String str = "I LoVE JaVA PROGRAMMING";    
        String engStr = str.toLowerCase(Locale.ENGLISH);  
        System.out.println(engStr);   
    }  
}

Output:

run:
i love java programming
BUILD SUCCESSFUL (total time: 1 second)