Java String to Lowercase

Java String to Lowercase | Sometimes there might be a scenario to convert all the letters or words to lowercase. In this case, retyping each and every word might be time-consuming so to avoid that Java has brought a method called toLowerCase(). And to convert the string to uppercase Java String class contains the toUpperCase() method.

In this blog, we convert the string to lowercase, to do this we use the toLowerCase() method. This method is a built-in method in the Java String class that helps us to convert the characters to lowercase. Details of the toLowerCase() method are as follows:-

1. public String toLowerCase( )
Parameters: It does not take any parameters.
Returns: It returns the string which is converted to lowercase.

2. public String toLowerCase(Locale locale)
It converts all of the characters in this String to lowercase using the rules of the given Locale.
Parameters: Locale use the case transformation rules for this locale
Returns: It converted string.

For converting String to uppercase, lowercase, alternative case, sentence case, and title case you can also take help from the online tools. See the below example which helps you to understand more about the topic.
1. String = “HAPPY”
Resultant string = “happy”
2. String = “Parrot”
Resultant string = “parrot”
3. String = “aNiMal”
Resultant string = “animal”

How to Make a String Lowercase in Java

Let us see a Java program to make a String lowercase in Java using the toLowerCase() method defined in the Java String class. We will define a string and call the toLowerCase() method on the given string.

Java String to Lowercase Program using toLowerCase()

public class Main {
   public static void main(String args[]) {
      String string = "JAVA PROGRAMMING LANGUAGE";
      System.out.println("String: " + string);
      string = string.toLowerCase();
      System.out.println("Resultant String: " + string);


Resultant String: java programming language

Java Convert String To Lowercase

In the previous example we used string literal, but this time we will use a String class constructor and then call the toLowerCase() method to convert the given string to lowercase.

Program to convert a string to all lowercase in Java

public class Main {
   public static void main(String args[]) {
      String string = new String("Java PrOGRAmmING lANGUAge");
      System.out.println("Lowercase string: " + string.toLowerCase());


Lowercase string: java programming language

Java How To Make String Lowercase

We can also convert the string to lowercase using the rules of the given Locale. First, we have to create an object for the Locale and pass it to the toLowerCase() method as a parameter.

import java.util.Locale;

public class Main {
   public static void main(String args[]) {
      String str = "ΙΧΘΥΣ" + "\u0130";
      String str1 = "TITLE";

      Locale turkish = Locale.forLanguageTag("tr");
      Locale english = Locale.forLanguageTag("en");

      String string1 = str.toLowerCase(turkish);
      String string2 = str.toLowerCase(english);
      System.out.println("String: " + str);
      System.out.println("Turkish: " + string1);
      System.out.println("English: " + string2);

      System.out.println("String: " + str1);
      System.out.println("Turkish: " + str1.toLowerCase(turkish));
      System.out.println("English: " + str1.toLowerCase(english));


String: ΙΧΘΥΣİ
Turkish: ιχθυσi
English: ιχθυσi̇
String: TITLE
Turkish: tıtle
English: title

In the above example, “\u0130” is a Unicode character set. Unicode stands for universal characters code, which contains all countries speaking languages’ character codes. See more:- Unicode character set in Java

Notice that the string “TITLE” is converted to “tıtle” in the Turkish locale whereas it is converted to “title” in the English locale.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Leave a Comment

Your email address will not be published. Required fields are marked *