Java String toLowerCase()

The toLowerCase() method converts all characters in the string to lowercase characters.

Example

class Main {
  public static void main(String[] args) {
    String str1 = "JAVA PROGRAMMING";

    // convert to lower case letters
System.out.println(str1.toLowerCase());
} } // Output: java programming

Syntax of toLowerCase()

The syntax of the string toLowerCase() method is:

string.toLowerCase()

Here, string is an object of the String class.


toLowerCase() Parameters

The toLowerCase() method does not take any parameters.


toLowerCase() Return Value

  • returns a string with all upper case letters converted to lowercase letters

Example: Java toLowerCase()

class Main {
  public static void main(String[] args) {
    String str1 = "Learn Java";
    String str2 = "Java123";

    // convert to lowercase letters
System.out.println(str1.toLowerCase()); // "learn java" System.out.println(str2.toLowerCase()); // "java123"
} }

As you can see from the above example, toLowerCase() converts all uppercase letters to lower case letters.


toLowerCase() With Locale Parameter

The toLowerCase() method can also take a locale as an argument. This allows you to convert characters in a string to lowercase using the given Locale (such as: Turkish, Lithuanian etc.) rules.

Its syntax is:

string.toLowerCase(Locale locale)

If you do not pass the locale parameter, the default locale, Locale.getDefault(), is used.

To learn more, visit Java toLowerCase() With Locale.


To convert all characters in a string to upper case characters, use the Java String toUpperCase() method.

Did you find this article helpful?