Java Tutorial Java Advanced Java References

Java String - toLowerCase() Method



The Java toLowerCase() method returns the string with all characters of the specified string in lowercase, using the rules of the default locale or specified locale.

Syntax

public String toLowerCase()
public String toLowerCase(Locale locale)

Parameters

locale specify locale to use the case transformation rules.

Return Value

Returns the lowercased version of the specified string.

Example:

In the example below, toLowerCase() method is used to convert all characters of the given string in the lowercase, using default locale.

public class MyClass {
  public static void main(String[] args) {
    String MyString = "HeLLo John!";
    String NewString = MyString.toLowerCase();

    System.out.println(NewString);
  }
}

The output of the above code will be:

hello john!

Example:

In the example below, French locale is used to convert all characters of the given string in the lowercase.

import java.util.Locale;

public class MyClass {
  public static void main(String[] args) {
    String MyString = "HeLLo John!";
    Locale locale = new Locale("fr", "FR");

    String NewString = MyString.toLowerCase(locale);

    System.out.println(NewString);
  }
}

The output of the above code will be:

hello john!

❮ Java String Methods