The method toLowerCase()
is used to convert all the characters of a String into lower-case characters. If you have a string with all upper-case characters or a mixture of upper-case and lower-case characters then this method converts the entire string into lower-case.
Java toLowerCase() Example
- Input:"HeLLo"
Output:"hello"
- Input:"CODESDOPE"
Output:codesdope
Java toLowerCase() Syntax
String.toLowerCase();
toLowerCase() Parameter
No parameters are used in this method.
toLowerCase() Return
This method returns a string in lowercase characters.
Program
package codesdope;
import java.util.*;
public class codesdope
{
public static void main(String[] args)
{
String s1="WELCOme TO CODEsdoPE";
String s2="HELLO WORLD";
String s3="coding";
System.out.println(s1.toLowerCase()); //case-1
System.out.println(s2.toLowerCase()); //case-2
System.out.println(s3.toLowerCase()); //case-3
}
}
welcome to codesdope
hello world
coding
- In the first case, when we have applied the
toLowerCase()
method on the strings1
i.e., "WELCOme TO CODEsdoPE" then this method converted all characters in the lower-case and returned the string in lower-case "welcome to codesdope". - In the second case, when we have applied the
toLowerCase()
method on the strings2
i.e "HELLO WORLD" then this method converted all characters in the lower-case and returned the string in lower-case "hello world". - In the third case, when we have applied the
toLowerCase()
method on the strings3
i.e "coding" then this method returned the same string because the string was already in the lower-case.