Java String toLowerCase() Method (original) (raw)

Last Updated : 23 Dec, 2024

**Java String toLowerCase() method is used to convert all letters to lowercase in a given string.

Example:

Java `

import java.util.*;

class Geeks { public static void main(String args[]) { // Custom input string String s = "Geeks for Geeks";

    // Converting string s to lowercase letter 
    String s2 = s.toLowerCase(); 

    System.out.println(s2); 
} 

}

`

Syntax of toLowerCase()

public String **toLowerCase ()

**Return Value : Returns a string in lowercase letter.

Internal Working of toLowerCase()

The Locale class is part of java.util package. It is used for extracting and manipulating the information. Locale object represents a geographical, political, or cultural region.

The package view of the method is as follows:

–> java.util **Package
–> String **Class
–> toLowerCase() **Method

**Example Statement

// Creates a Locale for the English language
Locale locale1 = new Locale(“en”);

It plays a vital role in toLowerCase() conversion where it checks the elements and helps to convert them into Lower Case. To know more about the topic refer to Locale article.

**Note: Internally toLowerCase() works in similar way as toLowerCase(Locale.getDefault()) method.

**Java toLowerCase(Locale loc)

Converts all the characters into lowercase using the rules of the given Locale.

**Syntax of toLowerCase()

public String **toLowerCase (Locale _loc)

**Example:

Java `

// Working of toLowerCase() Method // present inside Locale class import java.util.Locale;

class Geeks {

public static void main(String args[]) {
  
   String s = "I Know YOI Bui You Don't Know ME";

    // Locales with the language "tr" for TURKISH
    //"en" for ENGLISH is created
    Locale TURKISH = Locale.forLanguageTag("tr");
    Locale ENGLISH = Locale.forLanguageTag("en");

    // Converting string s to lowercase letter
    // using TURKISH and ENGLISH language
    String str1 = s.toLowerCase(TURKISH);
    String str2 = s.toLowerCase(ENGLISH);

    System.out.println(str1);
    System.out.println(str2);
}

}

`

Output

ı know yoı bui you don't know me i know yoi bui you don't know me