How to Convert a String into Lowercase in Java? | Variants of toLowerCase() Method

In the last tutorial, we have learned Java String’s lastIndexOf() method. We have learned all the four variants of this method with an example. In this tutorial, we will learn how to convert a string into a lowercase in java. We can convert all the characters of a string into lowercase by using the toLowerCase() method of the Java String Class.

Types of toLowerCase() Method

There are two variants of the toLowerCase() method in Java. In this tutorial, we will discuss all the two variants of this method.

1. toLowerCase()

This is the first variant of toLowerCase() method of string class. This method converts all the characters of a string into lowercase. This is equivalent to calling toLowerCase(Locale.getDefault).

Syntax: The syntax of the first variant of the toLowerCase() method is given below

public String toLowerCas()

Java Program to Convert String to Lowercase

class toLowerCase{
public static void main(String args[]){
String str = "String Tutorial BY BTechGeeks";
//converting all the characters of
//a string into lowecase.
System.out.println(str.toLowerCase());
}
}

Output:

string tutorial by btechgeeks

2. toLowerCase(Locale locale)

This is the second variant of the Java String toLowerCase() method. It converts all the characters in this String to lower case using the rule of the given locale.

Syntax: The syntax of the second variant of the toLowerCase() method is given below:

public String toLowerCase(Locale locale)

Also, Check:

Java String toLowerCase(Locale locale) Method Example

import java.util.Locale;
class toLowerCase{
public static void main(String args[]){
String str = "StrIng TutorIal BY JavaStudyPoint";

//Locales with the language "tr"
//for turkish and "en" for english.
Locale turkish = Locale.forLanguageTag("tr");
Locale english = Locale.forLanguageTag("en");

//converting string str into lowercase
//using turkish and english language.
String str1 = str.toLowerCase(turkish);
String str2 = str.toLowerCase(english);
System.out.println(str1);
System.out.println(str2);
}
}

Output:

How to Convert a String into Lowercase in Java