Java Convert String toLowerCase

In this example, we shall show you how to convert a String toLowerCase in Java. The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.

1. Java Convert String toLowerCase

To convert a String toLowerCase in Java, one should perform the following steps:

java toLowerCase
  • Create a new String
  • Use toLowerCase() API method of String. This method converts all of the characters in this String to lower case using the rules of the default locale. This is equivalent to calling toLowerCase(Locale.getDefault())

Note that in case you’d like to do the opposite, there is the toUpperCase method. The toUpperCase method works exactly like the toLowerCase, but converts the string to only contain capital letters instead of lower case.

In the code snippet below you can see an example of the conversion:

public class ConvertStringToLowerCase {
    public static void main(String[] args) {
        String s = "Java Code Geeks";
        System.out.println("Original String: " + s);
        String su = s.toLowerCase();
        System.out.println("String to lower case: " + su);


Original String: Java Code Geeks
String to lower case: java code geeks

Here we just create a String s, then we print it. Afterwards, we create a new string and we assign the value that is returned from toLowerCase method when called by the previously created string. In the end, we print the result of the “su” string. The result is the same string but all the letters are in lower case, exactly what we expected

2. Download the Source code

 This was an example of how to convert a String toLowerCase in Java.

You can download the full source code of this example here: Java Convert String toLowerCase

Last updated on May 4th, 2020

Ilias Tsagklis

Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button