Java String toLowerCase() method example

HQ » Java Tutorial » java.lang » String » toLowerCase() method example
Java String toLowerCase() method example 2018-02-19T13:06:35+00:00

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.

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 :


Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.