java.lang.String toLowerCase()

Description :

This java tutorial shows how to use the split() method of String class of java.lang package. This method returns a new String object as a string representation in lower case of our String. The toLowerCase() method is simply converts the string object into lower case.

Method Syntax :

public String[] split(String regex,int limit)

Parameter Input :

DataType Parameter Description

Method Returns :

This String toLowerCase() method returns a new String object. The new string object is equal to String in lower case format.

Compatibility Version :

Requires Java 1.1 and up

Exception :


Discussion :

Since a String can never be changed once instantiated, thus a new string object variable is required to hold the new string. This method is helpful especially if we are comparing data which comes from different systems.

In my experience as a developer, usually the strings that comes from user inputs are on different format. Sometimes all caps, or all are small caps and sometimes the First letter is in big letter only. To normalize this kind of situation before storing the information, I usually convert first the information into lower case.

Java Code Example :

This example source code demonstrates the use of toLowerCase() of String class. The example provided, makes use of the String equals() method to check equality.


 * Example source code for toLowerCase method of String class

public class StringtoLowerCaseDemo {

	public static void main(String[] args) {
		// declaring our String object
		String name = "AlberT einstein";
		// string object converted to lower case and check for String equality
		if(name.toLowerCase().equals("albert einstein")){
			System.out.println("Name does not match");



Sample Output :

Running the toLowerCase() method example source code of String class will give you the following output.

string toLowerCase method example

string toLowerCase method example

Exception Scenario :


Similar Method :

  • java.lang.String split(String regex)

Suggested Reading List :