String toLowerCase(Locale locale) method in java

Let’s learn String toLowerCase(Locale locale) method in java.

String toLowerCase(Locale locale) method in java

String toLowerCase() method returns the String, converted to lowercase.

This is equivalent to calling toLowerCase(Locale.getDefault()).

Syntax:

public String toLowerCase()

Also read – Strings in java

Now let’s see example on String toLowerCase() method.

import java.util.*;
public class StringToLowerCaseMethodExample
{
   public static void main(String[] args)
   {
      String str = "HELLOWORLD CORE jAva";
      String strLower = str.toLowerCase();
      System.out.println(strLower);
   }
}


Output:

helloworld core java


String toLowerCase(Locale locale) method converts all of the characters in this String to lowercase using the rules of the given Locale.

Syntax:

public String toLowerCase(Locale locale)

Now let’s see example on String toLowerCase(Locale locale) method.

import java.util.Locale;
public class StringToLowerCaseMethodExample
{
   public static void main(String[] args)
   {
      String str = "HELLOWORLD sTrInG";
      String strEnglish = str.toLowerCase(Locale.ENGLISH);
      System.out.println(strEnglish);
      String strTurkish = str.toLowerCase(Locale.forLanguageTag("tr"));
      System.out.println(strTurkish);
   }
}


Output:

helloworld string
helloworld str?ng