Java String toLowerCase()

The java string toLowerCase() method converts all characters of the string into lowercase letter. There are two types of toLowerCase() method.

public String toLowerCase(Locale loc) and public String toLowerCase() Parameter: loc- locale value to be applied. converts all the characters into lowercase using the rules of given Locale. Returns: returns string in lowercase letter.

string in lowercase letter.

public class Test { public static void main(String args[]) { String str1="CPROGRAMCODING HEllo stRIng"; String s1=str1.toLowerCase(); System.out.println(s1); } }

cprogramcoding hello string
Java String toLowerCase(Locale locale) Method Example

This method allows us to pass locale too for the various langauges. Let's see an example below where we are getting string in english and turkish both.

import java.util.Locale; public class Test { public static void main(String[] args) { String s = "CPROGRAMCODING HEllo stRIng"; String eng = s.toLowerCase(Locale.ENGLISH); System.out.println(eng); String turkish = s.toLowerCase(Locale.forLanguageTag("tr")); System.out.println(turkish); } }

cprogramcoding hello string cprogramcod?ng hello str?ng