Skip to content
Related Articles

Related Articles

Java String toLowerCase() with Examples

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 01 May, 2022
View Discussion
Improve Article
Save Article

Java String toLowerCase() method is used and operated over string where we want to convert all letters to lowercase in a string.

There are two types of toLowerCase() method as follows: 

  1. toLowerCase()
  2. toLowerCase(Locale loc): Converts all the characters into lowercase using the rules of the given Locale.

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

Syntax:

public String toLowerCase()
public String toLowerCase(Locale loc) 

The package view of the method is as follows: 

--> java.util Package
    --> String Class
        --> toLowerCase() Method  

Parameter: Locale value to be applied 

Return Type: Returns string in lowercase letter

Example 1:

java




// Java Program to Demonstrate Working of
// toLowerCase() Method of String Class
  
// Importing required classes
import java.util.*;
  
// Main class
class GFG {
  
    // Main driver method
    public static void main(String args[])
    {
  
        // Custom input string
        String s = "Geeks for Geeks";
  
        // Converting string s to lowercase letter
        String s2 = s.toLowerCase();
  
        // Printing the lowercase string corresponding
        // to input string
        System.out.println(s2);
    }
}

Output

geeks for geeks

Example 2:

java




// Java program to demonstrate Working of toLowerCase()
// Method present inside Locale class
  
// Importing required classes
import java.util.Locale;
  
// Main class
class GFG {
  
    // Main driver method
    public static void main(String args[])
    {
        // Custom input string
        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 gfg2 = s.toLowerCase(TURKISH);
        String gfg3 = s.toLowerCase(ENGLISH);
  
        // Printing above string
        System.out.println(gfg2);
        System.out.println(gfg3);
    }
}

Output

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!