Java toLowerCase Method

The Java toLowerCase Method is one of the String Methods, which is useful to convert the given string into Lowercase letters. This article will show how to use Java String toLowerCase with an example.

Before we get into the example, the basic syntax of the Java toLowerCase is as shown below. Java Programming provides two different methods to convert the specified string into Lowercase letters.

The following Java toLowerCase function will not accept any parameters and convert all the characters in a specified string to lowercase using the rule of the default locale.

public String toLowerCase(); // It will return String 

//In order to use in program
String_Object.toLowerCase()

The following function will accept the Locale value as the parameter and convert the characters to lowercase using the user-specified locale.

public String toLowerCase(Locale locale);

//In order to use in program
String_Object.toLowerCase(Locale locale)
  • String_Object: Please specify the valid Object.
  • locale: Please specify the Locale you want to use while converting the String_Object characters to Lowercase. For example, English, Turkish, Latin, etc.

Java toLowerCase Method Example

The LowerCase method converts all the characters in a string to lowercase. This program will help to understand the toLowerCase method.

The first four statements will convert the previously declared text data to lowercase characters and assign them to Str1. Next, we used the toLowerCase StringMethod directly on string data. And the following Java System.out.println statements will print the output.

package StringFunctions;

public class ToLowerCaseMethod {
	public static void main(String[] args) {
		String str = "Free Java Tutorial at Tutorial GateWay";
		
		String str1 = str.toLowerCase();
		String str2 = "TUTORIAL GATEWAY".toLowerCase();
		String str3 = "JAVA TUTOIRIAL".toLowerCase();
		String str4 = "TrY tO ReAd ThIs SenTEnCe".toLowerCase();
		
		System.out.println( "New Lowercase String = " + str1);
		System.out.println( "New Lowercase String = " + str2);
		System.out.println( "New Lowercase String = " + str3);
		System.out.println( "New Lowercase String = " + str4);
	}
}
Java toLowerCase Method 1