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 :

[table]
DataType|Parameter|Description
N/A|N/A|N/A
[/table]

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 :

N/A

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.

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 :

N/A

Similar Method :

  • java.lang.String split(String regex)

Suggested Reading List :